More importantly than any of these things, he is hanging onto the head of a
very, very large sequence with (def lazytri (map triangle (range))). This
will lead to serious memory pressure, and perhaps eventually a slowdown as
this sequence takes up all the memory in his app and the GC strains to
Hi,
Am Donnerstag, 20. Juni 2013 15:19:40 UTC+2 schrieb John Holland:
>
> (defn triangle [n] (reduce + (range n)))
> (def lazytri (lazy-seq (map triangle (range
>
>
Some quick idea: here is a major difference in your clojure and your java
implementation. You always recompute the whole sum f
OK, with a coding improvement
(defn factors-sqrt [n]
(filter #(= 0 (mod n %)) (range 1 (+ 1 (Math/sqrt n )
(defn num-of-factors [n] (* 2 (count (factors-sqrt n
it works for 499. (Idea being factors come in pairs, each factor >
sqrt(x) corresponds to one > sqrt(x))
Was it just runnin
I'm working on problems at projecteuler.net in Clojure.
There is a particular problem that my code doesn't seem to work for. The
problem is:
==
The sequence of triangle numbers is generated by adding the natural
numbers. So the 7th triangle number would be 1 +