When I'm learning a new language one of the programs I write is a simple 
sieve of Eratosthenes; the julia code is shown below.
Julia is taking 70% longer than python 2.7.5 to execute the program - have 
I coded something incorrectly?

 Language Execution time (seconds)  C 0.106   pypy 0.323   python 1.26   
julia 2.177  


function primes(N)
    sieveTo = ceil(sqrt(N))
    S = ones(N)
    S[1] = 0
    for i in 1:sieveTo
        if S[i] > 0
            for j in i*i:i:N
                S[j] = 0
            end
        end
    end
    return(sum(S))
end

println(primes(10000000))

Reply via email to