Skip to content

Commit

Permalink
ismersenneprime: handle the very easy case M < 7
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Apr 18, 2017
1 parent e528159 commit b2fe53a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
1 change: 1 addition & 0 deletions src/Primes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ function ismersenneprime(M::Integer; check::Bool = true)
M >= 0 && isprime(length(b)) && !('0' in b) ||
throw(ArgumentError("The argument given is not a valid Mersenne Number (`M = 2^p - 1`)."))
end
M < 7 && return M == 3
return ll_primecheck(M)
end

Expand Down
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ end
# Lucas-Lehmer
@test !ismersenneprime(2047)
@test ismersenneprime(8191)
@test_throws ArgumentError ismersenneprime(3)
@test_throws ArgumentError ismersenneprime(9)
@test_throws ismersenneprime(9, check=true)
# test the following does not throw
Expand Down

0 comments on commit b2fe53a

Please sign in to comment.