Up to 100 it is relatively simple, if you remove the even numbers, the multiples of 3 (summing up their digits recursively gives 3 6 or 9), and those that end at 5, you end up with 25 numbers out of which 22 (88%) are primes. If you further exclude 49 which you should remember is 7^2 from the multiplication table, and 77 that is obviously divisible by 7, you are left with 22/23 chance a number that passes these exclusion criteria is not 91 and hence it is a prime.
The standard divisibility rule for 3, 6 and 9 in base 10 is to sum the digits until you only have one left and check if it's one of those. Here, 5+7=12, 1+2=3, so 57 is divisible by 3.
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.
The obvious and naive method described above is O(sqrt(N)). For N ~= 2 ^ 127, that is about 2 ^ 64. / The Lucas-Lehmer method described in the article is better (how much better is an exercise for the reader).
The HN rule is that anything can be posted if it is accessible to everyone, including via a paywall workaround if it has a paywall that is porous.
The community has converged on this being the least-worst approach after wrestling with the issue for well over a decade, and it's sufficient to helpfully post the archive link with a snarky editorial comment :)
i found out that most articles behind paywalls dont even need the wayback machine to be viewed
if you are using firefox, just enter reading mode and you can read the entire article without popups in your preferred background, text color, font, etc
What does this part mean? For example 57.
The standard divisibility rule for 3, 6 and 9 in base 10 is to sum the digits until you only have one left and check if it's one of those. Here, 5+7=12, 1+2=3, so 57 is divisible by 3.
That is it. That is all. Pish posh.
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.
https://archive.is/8R0Fq
The community has converged on this being the least-worst approach after wrestling with the issue for well over a decade, and it's sufficient to helpfully post the archive link with a snarky editorial comment :)
In other words, an icon showing whatever-wall status, submitter can add an alternate link, etc.
if you are using firefox, just enter reading mode and you can read the entire article without popups in your preferred background, text color, font, etc