Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Dear downvoter, care to explain the downvote? This community is based on sharing knowledge, something you clearly couldn't have possibly had the time to do...
I agree that a case-by-case approach is the appropriate way to go here. The "best" way (git approach) is not always applicable, as users may not want to review/merge changes
@semicolon Well comparing a single runtime on a single case is probably not the best way to measure performance. If you believe you have arrived at a better (more performant) solution than the currently accepted answer, add another answer and then we can have a meaningful discussion about performance. I continue to believe that the currently accepted solution is asymptotically better in memory and equal in time.
@semicolon I should have qualified my comment, sorry about it. My statement was related to the hidden price of calculating all primes up to N - the naïve Eratosthenes is O(N*log(N)*log(log(N))) operations and O(N) memory which means this is the first component of the algorithm that will run out of memory or time if N is really big. It doesn't get much better with the sieve of Atkin, so I concluded the algorithm will be less appealing than the foldl lcm [1..N], which needs a constant number of bigints.