| ▲ | WCSTombs 15 hours ago | |||||||||||||||||||||||||||||||
The example given in the article is 2^127 - 1, which was historically proved to be prime without computers using a clever method now known as the Lucas-Lehmer test. Your algorithm is not practical for that number. | ||||||||||||||||||||||||||||||||
| ▲ | Nevermark 14 hours ago | parent | next [-] | |||||||||||||||||||||||||||||||
Ah, but I can assure you, it is just that simple. If a number is not prime, then it is the product of at least two numbers smaller than itself. If any of them are larger than its square root, all others must be smaller, or their product would be larger than the candidate prime. Ergo, just check that the candidate is not evenly divisible by any number equal or lower than its square root. This reasoning holds, independent of scale. QED. Check mate. Shazam. | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
| ▲ | great_wubwub 15 hours ago | parent | prev [-] | |||||||||||||||||||||||||||||||
/r/whoosh | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||