## The Recamán sequence

In case you have watched the following video about the Recamán sequence.

and want to play around with it in Mathematica. Here is my code for doing so:

nums = {0};

For[i = 1, i < 66, i++,

If[nums[[-1]] – i > 0 && Position[nums, nums[[-1]] – i] === {}, nums = Append[nums, nums[[-1]] – i],

nums = Append[nums, nums[[-1]] + i]]

]

{{#[[1]], 0}, #[[2]]} & /@ Partition[Riffle[Mean[#] & /@ Partition[Riffle[nums, nums[[2 ;;]]], 2],

Abs[Differences[nums]]/2], 2];

Show[Show[

Table[Graphics[Circle[%[[i, 1]], %[[i, 2]], {(i) \[Pi], (i + 1) \[Pi]}]], {i, Length[%]}], ImageSize -> 1000], Plot[0, {x, 0, 91}],

Axes -> True]

(You may have to copy this by hand rather than copy/paste.)

This produces the following rather beautiful graphic (and answers the question posed in the video):