peterolson / BigInteger.js

An arbitrary length integer library for Javascript
The Unlicense
1.12k stars 187 forks source link

bigInt(4033).isPrime() is true but it should be false #166

Closed frewq closed 5 years ago

frewq commented 5 years ago

4033 is not prime. It is divisible by 37. I Don't know why is this happening.

And bigInt(4681).isPrime() is true. But 4681 is not prime. It is divisible by 31.

peterolson commented 5 years ago

@oogFranz Could you take a look at this?

peterolson commented 5 years ago

Should be fixed now. I changed the Miller-Rabin primality test witnesses to

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37

(See wikipedia for reference)

frewq commented 5 years ago

Now it works perfect. Thank You. ;)