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 <mefo...@gmail.com> 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.
>
>    usage: (lpf 364362978 2) => 8675309"
>   [n d]
>   (if (> d n)
>     (- d 1)
>     (recur
>      (#(if (zero? (rem % 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-episode-2-largest-prime-...
>
> Have at it!
>
> -m
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to