Blum integer: Difference between revisions

1,036 bytes added ,  10 months ago
add RPL
(New post.)
(add RPL)
Line 1,195:
7 => %24.9973:
9 => %24.9848:</pre>
=={{header|RPL}}==
Blum integers are necessarily of the form 4k + 21, which allows to speed up the quest.
{{works with|HP|49}}
≪ FACTORS
'''CASE'''
DUP SIZE 4 ≠ '''THEN''' DROP 0 '''END'''
LIST→ DROP ROT * 1 ≠ '''THEN''' DROP2 0 '''END'''
4 MOD SWAP 4 MOD * 9 == '''END'''
≫ '<span style="color:blue">BLUM?</span>' STO
≪ { } 17
'''DO'''
4 +
'''IF''' DUP <span style="color:blue">BLUM?</span> '''THEN''' SWAP OVER + SWAP '''END'''
'''UNTIL''' OVER SIZE 50 == '''END'''
50 SWAP
'''DO'''
4 +
IF DUP <span style="color:blue">BLUM?</span> '''THEN''' SWAP 1 + SWAP '''END'''
'''UNTIL''' OVER 26828 == '''END'''
NIP
≫ '<span style="color:blue">TASK</span>' STO
{{out}}
<pre>
2: { 21 33 57 69 77 93 129 133 141 161 177 201 209 213 217 237 249 253 301 309 321 329 341 381 393 413 417 437 453 469 473 489 497 501 517 537 553 573 581 589 597 633 649 669 681 713 717 721 737 749 }
1: 524273
</pre>
Runs in 10 minutes 55 on the iHP48 emulator.
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby" line>require 'prime'
1,150

edits