Yellowstone sequence: Difference between revisions

(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
Line 2,364:
Found 30 Yellowstone numbers
done...
</pre>
 
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
{| class="wikitable"
! Code
! Comments
|-
|
'''IF''' DUP2 < '''THEN''' SWAP '''END'''
'''WHILE''' DUP '''REPEAT''' SWAP OVER MOD '''END'''
DROP
≫ 'GCD' STO
DUP DUP SIZE GET OVER DUP SIZE 1 - GET → am1 am2
≪ 3 '''DO'''
'''DO''' 1 + '''UNTIL''' DUP2 POS NOT '''END'''
'''UNTIL''' DUP am1 GCD 1 == OVER am2 GCD 1 ≠ AND '''END'''
+
≫ ≫ 'YELLO' STO
|
''( a b -- gcd(a,b) )''
Ensure a > b
Euclidean algorithm
''( { a(1)..a(n-1) } -- { a(1)..a(n) } )''
Store locally a(n-1) and a(n-2)
Find smallest number not already in sequence
Check primality requirements
Add a(n) to the sequence
|}
The following words in the command line deliver what is required:
{ 1 2 3 }
≪ 1 27 START YELLO NEXT ≫ EVAL
{{out}}
<pre>
1: { 1 2 3 4 9 8 15 14 5 6 25 12 35 16 7 10 21 20 27 22 39 11 13 33 26 45 28 51 32 17 ]
</pre>
 
1,150

edits