Yellowstone sequence: Difference between revisions

Added Easylang
(Add Scala implementation)
(Added Easylang)
Line 818:
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
Press enter to close</pre>
 
=={{header|EasyLang}}==
{{trans|Lua}}
<syntaxhighlight>
func gcd a b .
if b = 0
return a
.
return gcd b (a mod b)
.
proc remove_at i . a[] .
for j = i + 1 to len a[]
a[j - 1] = a[j]
.
len a[] -1
.
proc yellowstone count . yellow[] .
yellow[] = [ 1 2 3 ]
num = 4
while len yellow[] < count
for i to len notyellow[]
test = notyellow[i]
if gcd yellow[-2] test > 1 and gcd yellow[-1] test = 1
break 1
.
.
if i <= len notyellow[]
yellow[] &= notyellow[i]
remove_at i notyellow[]
else
while gcd yellow[-2] num <= 1 or gcd yellow[-1] num <> 1
notyellow[] &= num
num += 1
.
yellow[] &= num
num += 1
.
.
.
print "First 30 values in the yellowstone sequence:"
yellowstone 30 yellow[]
print yellow[]
</syntaxhighlight>
 
=={{header|Factor}}==
1,995

edits