Jump to content

Recaman's sequence: Difference between revisions

Easylang
(Easylang)
Line 991:
<pre>First 15 items: 0 1 3 6 2 7 13 20 12 21 11 22 10 23 9
First repeated item: A(24) = 42</pre>
 
=={{header|EasyLang}}==
<syntaxhighlight lang="easylang">
arrbase a[] 0
arrbase seen[] 0
len seen[] 100
#
a[] &= 0
seen[0] = 1
i = 1
repeat
h = a[i - 1] - i
if h <= 0 or seen[h] = 1
h = a[i - 1] + i
.
until seen[h] = 1
seen[h] = 1
a[] &= h
if i = 14
print a[]
.
i += 1
.
print h
</syntaxhighlight>
 
=={{header|Forth}}==
Line 1,034 ⟶ 1,059:
<pre>0 1 3 6 2 7 13 20 12 21 11 22 10 23 9
first repeated : a[20 ]=a[24 ]=42 ok</pre>
 
 
=={{header|FreeBASIC}}==
2,083

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.