Thanks for the tips. This indeed looks like an OpenJDK big int poor 
performance issue. For the reference, the results of two recur-based 
implementations:

user=> (defn fib [n]
#_=>   (loop [n n a 0N b 1N]
#_=>     (if (zero? n) a (recur (dec n) b (+ a b)))))
#'user/fib
user=> (time (rem (fib 1000000) 1000))
"Elapsed time: 53845.699995 msecs"

(defn recur-fibo [n]
  (letfn [(fib
       [current next n]
       (if (zero? n)
           current
         (recur next (+ current next) (dec n))))]
         (fib 0N 1N n)))

user=> (time (rem (recur-fibo 1000000) 1000))
"Elapsed time: 52966.393722 msecs"

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to