Sisyphus sequence: Difference between revisions
Content added Content deleted
(Created a new draft task and added a Wren example.) |
(add RPL) |
||
Line 39: | Line 39: | ||
<br> |
<br> |
||
=={{header|RPL}}== |
|||
This is a very slow version (15 minutes to get the 10,000th term on a HP-50g) , but I'm not sure to have enough memory to generate a large enough sieve to find the millionth term in a reasonable amount of time. |
|||
Anyway, even the first requirement (displaying 10 lines of 10 items) is out of range with a 22-character screen. |
|||
≪ 1 CF |
|||
'''IF''' DUP 0 < '''THEN''' 1 SF NEG '''END''' <span style="color:grey">@ A negative argument requires the sequence to be stored then displayed</span> |
|||
0 { 1 } → n cnt seq |
|||
≪ 2 1 |
|||
'''WHILE''' 'cnt' INCR n < '''REPEAT''' |
|||
'''IF''' DUP 2 MOD '''THEN''' OVER + SWAP NEXTPRIME SWAP '''ELSE''' 2 / '''END''' |
|||
'''IF''' 1 FS? '''THEN''' 'seq' OVER STO+ '''END''' |
|||
'''END''' |
|||
'''IF''' 1 FS? '''THEN''' DROP2 seq '''ELSE''' SWAP PREVPRIME R→C '''END''' |
|||
≫ ≫ '<span style="color:blue">SISYPH</span>' STO |
|||
-100 <span style="color:blue">SISYPH</span> |
|||
1000 <span style="color:blue">SISYPH</span> |
|||
10000 <span style="color:blue">SISYPH</span> |
|||
{{out}} |
|||
<pre> |
|||
3: {1 3 6 3 8 4 2 1 8 4 2 1 12 6 3 16 8 4 2 1 18 9 28 14 7 30 15 44 22 11 42 21 58 29 70 35 78 39 86 43 96 48 24 12 6 3 62 31 92 46 23 90 45 116 58 29 102 51 130 65 148 74 37 126 63 160 80 40 20 10 5 106 53 156 78 39 146 73 182 91 204 102 51 178 89 220 110 55 192 96 48 24 12 6 3 142 71 220 110 55 } |
|||
2: (990.,2273.) |
|||
1: (24975.,30713.) |
|||
</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{libheader|Wren-math}} |
{{libheader|Wren-math}} |