xclojure·12 ปีที่แล้ว·discussHere is a visualization of the number convergence:(loop [i 1 t [10N] v [1.0]] (if (> i 300) (map (fn [[a b]] (/ a b)) (partition 2 (interleave v t))) (recur (inc i) (conj t (* 10 (last t))) (conj v (+ (* 9 (last v)) (Math/pow 10 i))))))
xclojure·12 ปีที่แล้ว·discussWhy is it any better/faster than a simple switch case like this in Clojure: #(case % 1 31 2 28 3 31 4 30 5 31 6 30 7 31 8 31 9 30 10 31 11 30 12 31)
(loop [i 1 t [10N] v [1.0]] (if (> i 300) (map (fn [[a b]] (/ a b)) (partition 2 (interleave v t))) (recur (inc i) (conj t (* 10 (last t))) (conj v (+ (* 9 (last v)) (Math/pow 10 i))))))