Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
13
Task/Digital-root/Janet/digital-root.janet
Normal file
13
Task/Digital-root/Janet/digital-root.janet
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
(defn numbers [s] (filter (fn [y] (and (<= y 9) (>= y 0))) (map (fn [z] (- z 48)) (string/bytes s))))
|
||||
(defn summa [s] (reduce (fn [x y] (+ x y)) 0 (numbers s)))
|
||||
(defn minsumma [x p]
|
||||
(if (<= x 9)
|
||||
[x p]
|
||||
(minsumma (summa (string/format "%d" x)) (+ 1 p))))
|
||||
(defn test [t] (printf "%j" (minsumma (summa t) 1)))
|
||||
(test "627615")
|
||||
(test "39390")
|
||||
(test "588225")
|
||||
(test "393900588225")
|
||||
(test "19999999999999999999999999999999999999999999999999999999999999999999999999999999999999")
|
||||
(test "192348-0347203478-20483298402-39482-04720348-20394823-058720375204820-394823842-049802-93482-034892-3")
|
||||
Loading…
Add table
Add a link
Reference in a new issue