> Just thought you would like to know that Wolfram|Alpha agrees (in
> roughly the same time):
>
> http://www.wolframalpha.com/input/?i=factor+1234567890123456789012345...
Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Goo
Hi,
On Sep 10, 3:52 pm, MarkSwanson wrote:
> Just for fun I actually tried this:
>
> Clojure=> (time (lpf6b 1234567890123456789012345678901234567890))
> The prime factorization of 1234567890123456789012345678901234567890
> is :5964848081
> "Elapsed time: 5519.278432 msecs"
>
> I can't confirm th
What about a golf competition on the golf competition scorer? Then we
can evaluate that using;
(defmacro score-scorer [scorer] ... )
:)
- Adrian
On Thu, Sep 10, 2009 at 8:12 AM, Christophe Grand wrote:
>
> I propose to compute the score of a golf competition entry using this
> function:
> (d
I propose to compute the score of a golf competition entry using this function:
(defn score [expr] (count (tree-seq coll? #(if (map? %) (apply concat
%) (seq %)) expr)))
Thus, shorter names and literal anonymous closures won't change the score.
On Thu, Sep 10, 2009 at 1:50 AM, Timothy
Pratley wr
Just for fun I actually tried this:
Clojure=> (time (lpf6b 1234567890123456789012345678901234567890))
The prime factorization of 1234567890123456789012345678901234567890
is :5964848081
"Elapsed time: 5519.278432 msecs"
I can't confirm the answer is correct.
5.5 seconds sure beats 10 minutes. :-)
I took a stab at it. I used:
(set! *warn-on-reflection* true)
but it didn't tell me anything.
I found a Java class that did the same thing and created a Clojure
implementation from that. I thought that perhaps if I could force the
data types to be BigInteger Clojure would save time by not having
> (zero? (rem % d))
(= 0 (rem % d))
> (- d 1)
presumably you chose this instead of (dec d) because it converts one
real character into whitespace
so if you make this:
> (inc d
(+ d 1)
You can convert another whitespace! [arguably its a meaningful
whitespace but lets ignore that for
Why did you define the problem as you did rather than simply "The
largest prime factor of n?"
On Sep 9, 1:39 pm, Fogus wrote:
> ;; largest prime factor
> (defn lpf
> "Takes a number n and a starting number d > 1
> and calculates the largest prime factor of n
> starting at number d.
>
>
(recur (/ % d))
%)
n)
(inc d
This is the smallest `lpf` that I could come up with -- can you do
better? Can you make it faster (shouldn't be too hard, considering
mine is atrociously slow)?
More information at:
http://blog.fogus.me/2009/09/09/clojure-golf-episod