Find prime n such that reversed n is also prime: Difference between revisions
Find prime n such that reversed n is also prime (view source)
Revision as of 16:30, 19 February 2023
, 1 year ago→{{header|RPL}}
(→bc: add) |
|||
Line 1,326:
found 34 primes
done...
</pre>
=={{header|RPL}}==
This program uses the words <code>RVSTR</code> and <code>BPRIM?</code>, respectively made to [[Reverse_a_string#RPL|revert a string]] and to [[Primality_by_trial_division#RPL|test primality by trial division]]
≪ { } 1 499 '''FOR''' n
'''IF''' n R→B '''BPRIM? THEN'''
'''IF''' n →STR '''RVSTR''' STR→ R→B '''BPRIM? THEN''' n + '''END'''
'''END'''
'''NEXT'''
≫ EVAL
{{out}}
<pre>
1: { 2 3 5 7 11 13 17 31 37 71 73 79 97 101 107 113 131 149 151 157 167 179 181 191 199 311 313 337 347 353 359 373 383 389 }
</pre>
|