Jump to content

Emirp primes: Difference between revisions

(Added XPL0 example.)
Line 4,017:
return true
</syntaxhighlight>
 
=={{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]]. Requirement 3 of the task needs too much execution time to be allowed by the emulator watchdog timer.
{{works with|Halcyon Calc|4.2.7}}
≪ 0 SWAP
IF DUP R→B '''BPRIM?''' THEN
→STR DUP '''RVSTR'''
IF DUP ROT ≠ THEN STR→ R→B '''BPRIM?''' OR DUP END
END DROP
≫ ''''BMIRP?'''' STO
 
≪ { } 13 WHILE OVER SIZE 20 < REPEAT
IF DUP '''BMIRP?''' THEN DUP ROT SWAP + SWAP END
2 +
END DROP
{ } 7700 8000 FOR n
IF n '''BMIRP?''' THEN n + END
NEXT
≫ EVAL
{{out}}
<pre>
2: { 13 17 31 37 71 73 79 97 107 113 149 157 167 179 199 311 337 347 359 389 }
1: { 7717 7757 7817 7841 7867 7879 7901 7927 7949 7951 7963 }
</pre>
 
=={{header|Ruby}}==
1,151

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.