Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Digital-root/Clojure/digital-root.clj
Normal file
12
Task/Digital-root/Clojure/digital-root.clj
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(defn dig-root [value]
|
||||
(let [digits (fn [n]
|
||||
(map #(- (byte %) (byte \0))
|
||||
(str n)))
|
||||
sum (fn [nums]
|
||||
(reduce + nums))]
|
||||
(loop [n value
|
||||
step 0]
|
||||
(if (< n 10)
|
||||
{:n value :add-persist step :digital-root n}
|
||||
(recur (sum (digits n))
|
||||
(inc step))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue