Simple prime number test 1000 slower than trivial python?

Actually, you need to take care here. Firstly, your input value is so large that it’s not an Int, it’s an Int128:

julia> typeof(10000001829379821798314198278324234)
Int128

The square root is not outside the range of Int64, but with larger inputs you can get into trouble.

And secondly: Int(floor(sqrt(n))), gives you the wrong number:

julia> n = 10000001829379821798314198278324234
10000001829379821798314198278324234

julia> Int(floor(sqrt(n)))  # you should rather use floor(Int, sqrt(n)), actually
100000009146898688

julia> isqrt(n) # this is the largest integer m such that m^2 < n
100000009146898690
2 Likes