Successive prime differences: Difference between revisions
Content added Content deleted
(Added XPL0 example.) |
(added RPL) |
||
Line 2,483: | Line 2,483: | ||
done... |
done... |
||
</pre> |
</pre> |
||
=={{header|RPL}}== |
|||
{{works with|HP|49}} |
|||
« DUP SIZE 1 + { } DUP 0 → diff n first last count |
|||
« 1 |
|||
2 n '''START''' DUP NEXTPRIME '''NEXT''' |
|||
'''WHILE''' DUP 1000000 < '''REPEAT''' |
|||
n ROLL DROP DUP NEXTPRIME |
|||
n DUPN n →LIST |
|||
'''IF''' DUP ΔLIST diff == '''THEN''' |
|||
1 →LIST |
|||
'''IF''' first SIZE THEN 'last' '''ELSE''' 'first' '''END''' STO |
|||
1 'count' STO+ |
|||
'''ELSE''' DROP '''END''' |
|||
'''END''' |
|||
n DROPN first last + count |
|||
» » '<span style="color:blue">SUCCP</span>' STO |
|||
{ 2 4 } <span style="color:blue">SUCCP</span> |
|||
{{out}} |
|||
<pre> |
|||
2: { { 5 7 11 } { 999431 999433 999437 } } |
|||
1: 1393 |
|||
</pre> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
Line 2,504: | Line 2,528: | ||
[6, 4, 2] has 306 sets. [31, 37, 41, 43]...[997141, 997147, 997151, 997153] |
[6, 4, 2] has 306 sets. [31, 37, 41, 43]...[997141, 997147, 997151, 997153] |
||
</pre> |
</pre> |
||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
<syntaxhighlight lang="rust"> |
<syntaxhighlight lang="rust"> |