Erdös-Selfridge categorization of primes: Difference between revisions

Content added Content deleted
m (→‎{{header|J}}: some docs for people who are not comfortable reading J)
m (→‎{{header|J}}: grammar)
Line 360: Line 360:
Explanation: this is a recursive function defined only on primes. We memoize it for good performance.
Explanation: this is a recursive function defined only on primes. We memoize it for good performance.


To find the prime category of a prime, we find the prime factorization of the next larger integer, and find the category of each of those factors other than 2 or 3. The category 1 one greater than the maximum of these categories (with an explicit 0 for the maximum when there are no such factors)
To find the prime category of a prime, we find the prime factorization of the next larger integer, and find the category of each of those factors other than 2 or 3. The prime's category is one greater than the maximum of these factor categories (with an explicit 0 for the maximum when there are factors greater than 3)


First 200 primes -- category is in left box, primes are in right box:
First 200 primes -- category is in left box, primes are in right box: