Prime numbers which contain 123: Difference between revisions
Content added Content deleted
m (→{{header|Factor}}: they can't end in 5...) |
m (→{{header|Factor}}: zip assoc-invert -> swap zip) |
||
Line 60: | Line 60: | ||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
{{works with|Factor|0.99 2021-06-02}} |
{{works with|Factor|0.99 2021-06-02}} |
||
<lang factor>USING: assocs |
<lang factor>USING: assocs formatting grouping io kernel literals math |
||
math.functions math.functions.integer-logs math.primes |
|||
math.statistics sequences sequences.extras sequences.product |
|||
sorting tools.memory.private tools.time ; |
|||
<< |
<< |
||
Line 93: | Line 93: | ||
10 group [ [ commas "%8s" printf ] each nl ] each nl |
10 group [ [ commas "%8s" printf ] each nl ] each nl |
||
[ [ 10^ commas ] [ length ] bi* ] assoc-map |
[ [ 10^ commas ] [ length ] bi* ] assoc-map |
||
unzip cum-sum [ commas ] map |
unzip cum-sum [ commas ] map swap zip |
||
[ "Found %7s such primes under %s.\n" printf ] assoc-each |
[ "Found %7s such primes under %s.\n" printf ] assoc-each |
||
] time</lang> |
] time</lang> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Decimal primes under 100,000 which contain '123': |
|||
1,123 1,231 1,237 8,123 11,239 12,301 12,323 12,329 12,343 12,347 |
|||
12,373 12,377 12,379 12,391 17,123 20,123 22,123 28,123 29,123 31,123 |
|||
31,231 31,237 34,123 37,123 40,123 41,231 41,233 44,123 47,123 49,123 |
|||
50,123 51,239 56,123 59,123 61,231 64,123 65,123 70,123 71,233 71,237 |
|||
76,123 81,233 81,239 89,123 91,237 98,123 |
|||
Decimal primes under 100,000 which contain '123': |
Decimal primes under 100,000 which contain '123': |
||
1,123 1,231 1,237 8,123 11,239 12,301 12,323 12,329 12,343 12,347 |
1,123 1,231 1,237 8,123 11,239 12,301 12,323 12,329 12,343 12,347 |
||
Line 111: | Line 118: | ||
Found 43,548 such primes under 100,000,000. |
Found 43,548 such primes under 100,000,000. |
||
Found 435,853 such primes under 1,000,000,000. |
Found 435,853 such primes under 1,000,000,000. |
||
Running time: |
Running time: 21.938685601 seconds |
||
</pre> |
</pre> |
||