On Thursday, February 13, 2014 10:34:32 AM UTC-5, Stefan Karpinski wrote: > > Did you code this up in Python too? There's a built-in Julia function > called primes (written in pure > Julia<https://github.com/JuliaLang/julia/blob/master/base/primes.jl>), > which implements a prime number sieve efficiently: > > julia> @time primes(10000000); > elapsed time: 0.167461201 seconds (6581064 bytes allocated) > > Obviously the times are apples to oranges since we're on different > machines, but it looks to be comparable to your C version. Also, on my > system, your version runs in much less time: >
Note that the built-in primes function actually returns a list of primes, rather than just counting the number of primes via an array of bits, so it is a bit slower. On my machine it is about 2x slower than my optimized version of James' code.
