Minimum primes: Difference between revisions
Content added Content deleted
No edit summary |
(add RPL) |
||
Line 621: | Line 621: | ||
</pre> |
</pre> |
||
=={{header|RPL}}== |
|||
====By the letter==== |
|||
{{works with|HP|49g}} |
|||
≪ {5 45 23 21 67} {43 22 78 46 38} {9 98 12 54 53} → numbers1 numbers2 numbers3 |
|||
≪ numbers1 numbers2 numbers3 3 ≪ MAX MAX ≫ DOLIST |
|||
{ } → max primes |
|||
≪ 1 max SIZE '''FOR''' j |
|||
max j GET |
|||
'''IF''' DUP ISPRIME? NOT '''THEN''' NEXTPRIME '''END''' |
|||
'primes' SWAP STO+ |
|||
'''NEXT''' primes |
|||
≫ ≫ ≫ '<span style="color:blue">TASK</span>' STO |
|||
{{out}} |
|||
<pre> |
|||
1: {43 101 79 59 67} |
|||
</pre> |
|||
====Idiomatic==== |
|||
No need for local variables. |
|||
≪ {5 45 23 21 67} {43 22 78 46 38} {9 98 12 54 53} |
|||
3 ≪ MAX MAX ≫ DOLIST |
|||
≪ '''IF''' DUP ISPRIME? NOT '''THEN''' NEXTPRIME '''END''' ≫ MAP |
|||
≫ '<span style="color:blue">TASK</span>' STO |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
<syntaxhighlight lang="ruby">require "prime" |
<syntaxhighlight lang="ruby">require "prime" |
||
Line 631: | Line 653: | ||
<pre>[43, 101, 79, 59, 67] |
<pre>[43, 101, 79, 59, 67] |
||
</pre> |
</pre> |
||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
<syntaxhighlight lang="ruby">var lists = [ |
<syntaxhighlight lang="ruby">var lists = [ |