This is just a first draft, happy to have the running code in about half an hour. I bet there's a lot of room for improvements, it calculates the first million numbers in 147 seconds.
Got it down to still very slow 100 seconds by using the vec function on the sieved result to make it a vector instead of a linked list. This way the nth call inside the recur statement is way faster.
As always: happy to provide a Clojure solution:
This is just a first draft, happy to have the running code in about half an hour. I bet there's a lot of room for improvements, it calculates the first million numbers in 147 seconds.
Got it down to still very slow 100 seconds by using the
vecfunction on the sieved result to make it a vector instead of a linked list. This way thenthcall inside therecurstatement is way faster.