Use the semi-circle diagram from Numberphile to visualize the Recamán's sequence:
In[]:=
(*MikkHeidema'sRecamanSeqfromOEISA005132*)​​RecamanSeq[i_Integer]:=Fold[With[{lst=Last@#,len=Length@#},Append[#,If[lst>len&&!MemberQ[#,lst-len],lst-len,lst+len]]]&,{0},Range@i];
Define a function that links adjacent items with a semi-circle based on their lexicographic order:
In[]:=
semiCircularPath[{u_Integer,v_Integer}]:=Withmid=Midpoint[{{u,u},{v,v}}],r=
2
Abs[u-v]2,​​If[u>v,Circle[mid,r,{-3π/4,π/4}],Circle[mid,r,{π/4,5*π/4}]]​​
Link all adjacent pairs with the corresponding semi-circles:
In[]:=
paths=semiCircularPath/@Partition[RecamanSeq[800],2,1];
Use AxisObject to add an axis along the diagonal line in the graphics. Wrap everything in the Manipulate function:
In[]:=
Manipulate[​​Graphics[{AxisObject[Line[{{0,0},2*{n,n}}],{0,2*n}],StandardOrange,paths[[1;;n]]},PlotRange->{{-.15n,2n},{-.15n,2*n}},ImagePadding->8,ImageSize->600,Background->Black],{{n,277},1,500,1},SaveDefinitions->True​​]
Out[]=
​
n
0
100
200
300
400
500
Create animation and save to a local “.mov” file:
In[]:=
LaunchKernels[];
In[]:=
frames=ParallelTable[Image@Graphics[{AxisObject[Line[{{0,0},2*{n,n}}],{0,2*n}],StandardOrange,paths[[1;;n]]},PlotRange->{{-.15n,2n},{-.15n,2*n}},ImagePadding->8,ImageSize->400],{n,1,400}];
In[]:=
Export["rq.mov",frames]
Out[]=
rq.mov
Click to play the spooky audio from the numbers:
In[]:=
keys=Mod[RecamanSeq[1000],48];
In[]:=
SeedRandom["Recaman"];
In[]:=
so=Sound[{SoundNote[#,RandomChoice[{0.1,0.2,0.05,0.06,0.07}],SoundVolume->RandomReal[{.5,1}]]&/@keys}]
Out[]=
Sound note overlap allowed:
In[]:=
SeedRandom["Recaman"];​​duration=RandomChoice[{0.1,0.2,0.05,0.06,0.07},1001];​​tInit=Accumulate[duration];​​Sound[MapThread[SoundNote[#,​​{#2,#2+#3}+RandomReal[{-0.1,0.05}],​​SoundVolume->RandomReal[{.3,1}]​​]&,{keys,tInit,duration}]​​]
Out[]=

CITE THIS NOTEBOOK

Recamán's sequence, semi circles and spooky sound​
by Shenghui Yang​
Wolfram Community, STAFF PICKS, October 26, 2025
​https://community.wolfram.com/groups/-/m/t/3565570