Created
February 9, 2012 01:48
-
-
Save mwmitchell/1776413 to your computer and use it in GitHub Desktop.
division expansion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn de [x n] | |
(loop [x x nr (vec (range 1 (+ n 1))) z []] | |
(let [q (quot x (last nr))] | |
(if-let [xx (not-empty (subvec nr 0 (- (count nr) 1)))] | |
(recur (- x q) xx (concat z [q])) | |
(concat z [q]))))) | |
(de 8 2) | |
(de 7 3) | |
(de 7 2) | |
(de 10 5) | |
(de 10 2) | |
(de 10 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment