Primes whose first and last number is 3: Difference between revisions
Content added Content deleted
(add RPL) |
(→{{header|RPL}}: improved generator) |
||
Line 950: | Line 950: | ||
Uses a candidate numbers generator to speed up execution. |
Uses a candidate numbers generator to speed up execution. |
||
{{works with|HP|49}} |
{{works with|HP|49}} |
||
≪ 10 + |
|||
≪ 2 OVER SIZE 1 - SUB →STR "9876543210" → prev digits |
|||
⚫ | |||
≪ 1 SF "" |
|||
prev SIZE 1 '''FOR''' j |
|||
digits DUP |
|||
prev j DUP SUB POS 1 FS? - |
|||
'''IF''' DUP NOT '''THEN''' DROP digits SIZE '''ELSE''' 1 CF '''END''' |
|||
DUP SUB SWAP + |
|||
-1 '''STEP''' |
|||
⚫ | |||
"3" SWAP OVER + + STR→ |
|||
≫ ≫ '<span style="color:blue">NXT3N3</span>' STO |
≫ ≫ '<span style="color:blue">NXT3N3</span>' STO |
||
≪ { |
≪ { } 3 |
||
'''WHILE''' DUP 4000 < '''REPEAT''' |
'''WHILE''' DUP 4000 < '''REPEAT''' |
||
'''IF''' DUP ISPRIME? '''THEN''' SWAP OVER + SWAP '''END''' |
'''IF''' DUP ISPRIME? '''THEN''' SWAP OVER + SWAP '''END''' |