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

m
→‎{{header|J}}: some docs for people who are not comfortable reading J
(J)
m (→‎{{header|J}}: some docs for people who are not comfortable reading J)
Line 357:
1+>./0,pcat(q:1+y)-.2 3
}}M."0</lang>
 
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)
 
First 200 primes -- category is in left box, primes are in right box:
6,951

edits