Jump to content

Pernicious numbers: Difference between revisions

add RPL
(→‎OCaml: add)
(add RPL)
Line 2,851:
The first 25 pernicious numbers:
3 5 6 7 9 10 11 12 13 14 17 18 19 20 21 22 24 25 26 28 31 33 34 35 36
</pre>
 
=={{header|RPL}}==
≪ '''IF''' DUP 5 ≤ '''THEN'''
{ 2 3 5 } SWAP POS
'''ELSE'''
'''IF''' DUP 2 MOD NOT '''THEN''' 2
'''ELSE'''
DUP √ CEIL → lim
≪ 3 '''WHILE''' DUP2 MOD OVER lim ≤ AND '''REPEAT''' 2 + '''END'''
'''END''' MOD
'''END''' SIGN
≫ ''''PRIM?'''' STO
BIN R→B →STR 0
1 3 PICK SIZE '''FOR''' j
'''IF''' OVER j DUP SUB "1" == '''THEN''' 1 + '''END NEXT'''
SWAP DROP '''PRIM?'''
≫ ´'''PERN?'''’ STO
≪ { } 1 '''WHILE''' OVER SIZE 25 < '''REPEAT IF''' DUP PERN? '''THEN''' SWAP OVER + SWAP '''END''' 1 + '''END''' DROP
≫ ´'''TASK1'''’ STO
≪ { } 888888877 888888888 '''FOR''' n '''IF''' n '''PERN? THEN''' n + '''END NEXT'''
≫ ´'''TASK2'''’ STO
{{out}}
<pre>
2: { 3 5 6 7 9 10 11 12 13 14 17 18 19 20 21 22 24 25 26 28 31 33 34 35 36 }
1: { 888888877 888888878 888888880 888888883 888888885 888888886 }
</pre>
 
1,150

edits

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