Closed stevengj closed 1 year ago
See this discourse comment.
It seems like this could be fixed with a little refactoring. Instead of having witnesses(n) return a variably sized tuple (which is not type stable), it would be better to inline this into isprime and do something like:
witnesses(n)
isprime
return n < 4294967296 ? checkwitnesses(n, _witnesses(UInt64(n))) : n < 2152302898747 ? checkwitnesses(n, (2, 3, 5, 7, 11)) : n < 3474749660383 ? checkwitnesses(n, (2, 3, 5, 7, 11, 13)): checkwitnesses(n, (2, 325, 9375, 28178, 450775, 9780504, 1795265022))
where checkwitnesses(n, witnesses) is simply this loop refactored into a function.
checkwitnesses(n, witnesses)
it can. I've done that refactoring in a local branch and never bothered to pr it.
this is fixed
See this discourse comment.
It seems like this could be fixed with a little refactoring. Instead of having
witnesses(n)
return a variably sized tuple (which is not type stable), it would be better to inline this intoisprime
and do something like:where
checkwitnesses(n, witnesses)
is simply this loop refactored into a function.