Composite numbers k with no single digit factors whose factors are all substrings of k: Difference between revisions

m
J
m (→‎{{header|Phix}}: added a slightly faster version)
m (J)
Line 76:
5526173 11610313 13436683 13731373 13737841 13831103 15813251 17692313 19173071 28118827
</pre>
 
=={{header|J}}==
 
<lang J> */2 3 5 7
210
#1+I.0=+/|:4 q:1+i.210
48</lang>
 
Or: 48 out of every 210 positive numbers have no single digit factors.
 
So, we can generate a few hundred thousand numbers, discard the primes (and 1), then check what's left using substring matching on the factors. (We allow '0' as a 'factor' in our substring test so that we can work with a padded array of factors, avoiding variable length factor lists.)
 
<lang J> 2{._10 ]\(#~ */"1@((+./@(E. '0 ',])~&>)&:(":&.>)q:))(#~ 1-1&p:)}.,(1+I.0=+/|:4 q:1+i.210)+/~210*i.2e5
15317 59177 83731 119911 183347 192413 1819231 2111317 2237411 3129361
5526173 11610313 13436683 13731373 13737841 13831103 15813251 17692313 19173071 28118827</lang>
 
 
=={{header|Julia}}==
6,951

edits