One-two primes: Difference between revisions
Content added Content deleted
(Created Nim solution.) |
(add RPL) |
||
Line 884: | Line 884: | ||
100: (8 x 91) 998998889 |
100: (8 x 91) 998998889 |
||
200: (8 x 190) 9888898989</pre> |
200: (8 x 190) 9888898989</pre> |
||
=={{header|RPL}}== |
|||
Candidate numbers are generated lexically by the <code>UP12</code> recursive function to speed up execution: the first 20 terms are found in 1 minute 39 seconds. |
|||
{{works with|HP|50g}} |
|||
≪ "" |
|||
1 ROT '''START''' "1" + '''NEXT''' |
|||
≫ ‘<span style=color:blue>REPUNIT</span>’ STO <span style=color:grey>@ ''(n → "11..1")''</span> |
|||
≪ |
|||
'''IF''' DUP '''THEN''' |
|||
DUP2 DUP SUB NUM 99 SWAP - CHR REPL |
|||
LASTARG ROT DROP |
|||
'''IF''' "1" == '''THEN''' 1 - <span style=color:blue>UP12</span> <span style=color:grey>@ factor the carry</span> |
|||
'''ELSE''' DROP '''END''' |
|||
'''ELSE''' DROP "1" SWAP + '''END''' |
|||
≫ ‘<span style=color:blue>UP12</span>’ STO <span style=color:grey>@ ''("121..21" n → "122..21")''</span> |
|||
≪ { } "2" |
|||
'''WHILE''' OVER SIZE 20 < '''REPEAT''' |
|||
DUP STR→ |
|||
'''IF''' DUP ISPRIME? '''THEN''' |
|||
ROT SWAP + SWAP |
|||
SIZE 1 + <span style=color:blue>REPUNIT</span> |
|||
'''ELSE''' |
|||
DROP DUP SIZE <span style=color:blue>UP12</span> |
|||
'''END''' |
|||
'''END''' DROP |
|||
≫ ‘<span style=color:blue>TASK</span>’ STO |
|||
{{out}} |
|||
<pre> |
|||
1: {2 11 211 2111 12211 111121 1111211 11221211 111112121 1111111121 11111121121 111111211111 1111111121221 11111111112221 111111112111121 1111111112122111 11111111111112121 111111111111112111 1111111111111111111 11111111111111212121} |
|||
</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |