Pan base non-primes: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (→{{header|Raku}}: Add correct header) |
Thundergnat (talk | contribs) m (→{{header|J}}: Works correctly but showing wrong count.) |
||
Line 34: | Line 34: | ||
Numeric strings where the greatest common divisor of all of the digits is more than 1 are composite in every base. |
Numeric strings where the greatest common divisor of all of the digits is more than 1 are composite in every base. |
||
If a "decimal" numeric string N is composite in every base up to base N, it is composite in every base. |
If a "decimal" numeric string N is composite in every base up to base N, it is composite in every base. |
||
The digit '''1''' is an odd-ball case as it is neither prime nor composite. It typically is ''not'' included, but due to the ambiguous wording, would not be wrong if it is. |
|||
Line 50: | Line 52: | ||
=={{header|J}}== |
=={{header|J}}== |
||
{{improve|J|Probably not doing anything wrong but there are 377 (378 if you include 1) pan-base non-primes up to 1000. 63 (64) is just the odd count}} |
|||
Implementation:<lang J>pbnp=: {{ if. 10 > y do. -.1 p: y return. end. |
Implementation:<lang J>pbnp=: {{ if. 10 > y do. -.1 p: y return. end. |
||
digits=. 10 #.inv y |
digits=. 10 #.inv y |