Pan base non-primes: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (minor tweaks) |
(J draft) |
||
Line 49: | Line 49: | ||
*; [[oeis:A121719|OEIS A121719 - Strings of digits which are composite regardless of the base in which they are interpreted. Exclude bases in which numbers are not interpretable.]] |
*; [[oeis:A121719|OEIS A121719 - Strings of digits which are composite regardless of the base in which they are interpreted. Exclude bases in which numbers are not interpretable.]] |
||
=={{header|J}}== |
|||
Implementation:<lang J>pbnp=: {{ if. 10 > y do. -.1 p: y return. end. |
|||
digits=. 10 #.inv y |
|||
*/0=1 p: ((>./digits)+i.y) #."0 1 digits |
|||
}}"0</lang> |
|||
Task examples:<lang J> 40{.1+I.pbnp 1+i.1e3 NB. first 40 pan based non primes |
|||
1 4 6 8 9 20 22 24 26 28 30 33 36 39 40 42 44 46 48 50 55 60 62 63 64 66 68 69 70 77 80 82 84 86 88 90 93 96 99 100 |
|||
20{.(#~ 2&|)1+I.pbnp 1+i.1e3 NB. first 20 odd pan based non primes |
|||
1 9 33 39 55 63 69 77 93 99 121 143 165 169 187 231 253 273 275 297 |
|||
#(#~ 2&|)1+I.pbnp 1+i.1e3 NB. number of pan based non primes up to 1000 |
|||
64 |
|||
100*(+/%#)2|1+I.pbnp 1+i.1e3 NB. percent odd pan based non primes up to 1000 |
|||
16.9761</lang> |
|||
=={{header|Perl}}== |
|||
<lang perl6>use Base::Any; |
<lang perl6>use Base::Any; |
||
use List::Divvy; |
use List::Divvy; |