Smarandache-Wellin primes: Difference between revisions
Content added Content deleted
(added RPL) |
|||
Line 1,000: | Line 1,000: | ||
19ᵗʰ: Index: 1086, 208614364610327343341589284471 |
19ᵗʰ: Index: 1086, 208614364610327343341589284471 |
||
20ᵗʰ: Index: 1187, 229667386663354357356628334581</pre> |
20ᵗʰ: Index: 1187, 229667386663354357356628334581</pre> |
||
=={{header|RPL}}== |
|||
The latest versions of RPL can handle large 500-digit integers, making it possible to search for the fifth SW prime. Unfortunately, even with an emulator, the primality test takes too long. |
|||
{{works with|HP|49}} |
|||
« "" 2 |
|||
1 4 ROLL '''FOR''' j |
|||
SWAP OVER + SWAP NEXTPRIME |
|||
'''NEXT''' DROP |
|||
» » '<span style="color:blue">→SW</span>' STO |
|||
« →STR → swn |
|||
« { 10 } 0 CON |
|||
1 swn SIZE '''FOR''' j |
|||
swn j DUP SUB STR→ 1 + DUP2 GET 1 + PUT |
|||
'''NEXT''' |
|||
"" |
|||
1 10 '''FOR''' j |
|||
OVER j GET + |
|||
'''NEXT''' |
|||
STR→ NIP |
|||
» '<span style="color:blue">DSW</span>' STO |
|||
« 0 → idx |
|||
« { } |
|||
'''WHILE''' DUP SIZE 3 < '''REPEAT''' |
|||
'''IF''' 'idx' INCR <span style="color:blue">→SW</span> DUP ISPRIME? '''THEN''' + '''ELSE''' DROP '''END''' |
|||
'''END''' |
|||
» » '<span style="color:blue">TASK1</span>' STO |
|||
« 0 → idx |
|||
« { } |
|||
'''WHILE''' DUP SIZE 3 < '''REPEAT''' |
|||
'''IF''' 'idx' INCR <span style="color:blue">→SW DSW</span> DUP ISPRIME? '''THEN''' + '''ELSE''' DROP '''END''' |
|||
'''END''' |
|||
» » '<span style="color:blue">TASK2</span>' STO |
|||
{{out}} |
|||
<pre> |
|||
2: { 2 23 2357 } |
|||
1: { 4194123321127 547233879626521 547233979727521 } |
|||
</pre> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |