Recaman's sequence: Difference between revisions
Content deleted Content added
Added Quackery. |
mNo edit summary |
||
Line 1,323:
The first duplicated term is a[24] = 42
lua: not enough memory</pre>
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<lang Mathematica>ClearAll[f]
f[s_List] := Block[{a = s[[-1]], len = Length@s},
Append[s, If[a > len && ! MemberQ[s, a - len], a - len, a + len]]]; g = Nest[f, {0}, 70]
g = Nest[f, {0}, 70];
Take[g, 15]
p = Select[Tally[g], Last /* EqualTo[2]][[All, 1]]
p = Flatten[Position[g, #]] & /@ p;
TakeSmallestBy[p, Last, 1][[1]]</lang>
{{out}}
<pre>{0,1,3,6,2,7,13,20,12,21,11,22,10,23,9}
{43,42,79,78}
{21,25}</pre>
=={{header|Microsoft Small Basic}}==
|