Primes whose first and last number is 3: Difference between revisions

add RPL
(add RPL)
Line 945:
Found 33 numbers
done...
</pre>
 
=={{header|RPL}}==
Uses a candidate numbers generator to speed up execution.
{{works with|HP|49}}
≪ 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'''
'''IF''' 1 FS? '''THEN''' digits DUP SIZE DUP SUB SWAP + '''END'''
"3" SWAP OVER + + STR→
≫ ≫ '<span style="color:blue">NXT3N3</span>' STO
≪ { 3 } 303
'''WHILE''' DUP 4000 < '''REPEAT'''
'''IF''' DUP ISPRIME? '''THEN''' SWAP OVER + SWAP '''END'''
<span style="color:blue">NXT3N3</span>
'''END''' DROP
≫ '<span style="color:blue">33PRIMES</span>' STO
{{out}}
<pre>
1: { 3 313 353 373 383 3023 3083 3163 3203 3253 3313 3323 3343 3373 3413 3433 3463 3533 3583 3593 3613 3623 3643 3673 3733 3793 3803 3823 3833 3853 3863 3923 3943 }
</pre>
 
Line 962 ⟶ 988:
Count of primes below 1000000 which start and en with 3: 2251
</pre>
 
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">func numbers_with_edges(upto, base = 10, s = [3]) {
1,150

edits