Composite numbers k with no single digit factors whose factors are all substrings of k: Difference between revisions
Content added Content deleted
m (J) |
m (→{{header|J}}) |
||
Line 86: | Line 86: | ||
Or: 48 out of every 210 positive numbers have no single digit factors. |
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.) |
So, we can generate a few hundred thousand lists of 48 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 |
<lang J> 2{._10 ]\(#~ */"1@((+./@(E. '0 ',])~&>)&:(":&.>)q:))(#~ 1-1&p:)}.,(1+I.0=+/|:4 q:1+i.210)+/~210*i.2e5 |
||
Line 92: | Line 92: | ||
5526173 11610313 13436683 13731373 13737841 13831103 15813251 17692313 19173071 28118827</lang> |
5526173 11610313 13436683 13731373 13737841 13831103 15813251 17692313 19173071 28118827</lang> |
||
Most of the time here is the substring testing, so this could be better optimized. |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |