3 ms·
Pumping the Primes
- msie 11y agoI looked up Matt Frank (mentioned in the article) and I see that he's now working in Finance. Surprise, surprise! :D
- dmichulke 11y agoFor the clojure people: (let [gcd (fn [x y] (if (pos? y) (recur y (mod x y)) x))] (->> [2 7 1] (iterate (fn [[n a]] (let [g (gcd n a)] [(inc n) (+ a g) g]))) (filter (comp #(< 1 %) last)) (take 20))) I would format it better if I knew how to. Anyway, the last element of each vector (that is, the g) in the resulting sequence is always a prime.
- dmichulke 11y agoRegarding run time, you can see there is no free lunch: The first twenty elements are returned in 4msecs. The first 200 are still running (> 2 hours already).