JuliaMath / Primes.jl

Prime numbers in Julia
Other
99 stars 32 forks source link

nextprime of a prime returns the same prime #96

Closed josd closed 3 years ago

josd commented 3 years ago

Using Primes v0.5.0 on Julia Version 1.7.0-DEV.1108 (2021-05-16) we get:

$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.0-DEV.1108 (2021-05-16)
 _/ |\__'_|_|_|\__'_|  |  Commit b1a4129338 (0 days old master)
|__/                   |

julia> using Primes

julia> nextprime(5)
5

julia> nextprime(97)
97

For non-primes it works fine:

julia> nextprime(8)
11
rfourquet commented 3 years ago

Yes this is expected and documented. This behaves the same as e.g. the same function in the PARI system, or:

julia> findnext([true, true], 1)
1