# Simple prime number test 1000 slower than trivial python?

**URL:** <https://discourse.julialang.org/t/simple-prime-number-test-1000-slower-than-trivial-python/15504>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [September 26, 2018, 9:22am UTC](https://discourse.julialang.org/t/simple-prime-number-test-1000-slower-than-trivial-python/15504 "2018-09-26T09:22:15Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [September 26, 2018, 10:27am UTC](https://discourse.julialang.org/t/simple-prime-number-test-1000-slower-than-trivial-python/15504/4 "2018-09-26T10:27:25Z")

</div>

> [@jling](#):
>
> `for i = 1:Int(floor(sqrt(n)))`

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
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
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

```

---

_[View the full topic](https://discourse.julialang.org/t/simple-prime-number-test-1000-slower-than-trivial-python/15504)._
