A210607 Vertex number of an L-toothpick structure which give Recamán's sequence A005132.
0, 1, 4, 9, 12, 16, 20, 25, 36
Offset: 1
This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
rr = {0}; r[0] = 0; r[n_] := r[n] = Module[{r1, rn}, r1 = r[n-1]; rn = If[r1-n >= 0 && FreeQ[rr, r1-n], r1-n, r1+n]; AppendTo[rr, rn]; rn]; Table[r[n], {n, 0, 100}] // Accumulate (* Jean-François Alcover, Aug 31 2022 *)
f[s_List] := Block[{a = b = 0, k = 1, l = s[[-1]], n = Length@ s}, While[ If[l > k*n && !MemberQ[s, l - k*n], a = l - k*n]; If[ !MemberQ[s, l + k*n], b = l + k*n; Break[]]; a == b == 0, k++]; Append[s, If[a > 0, a, b]]]; Nest[f, {0}, 70] (* Robert G. Wilson v, Sep 09 2016 *)
l=[0] for n in range(1, 101): i=1 while True: a=l[n - 1] x=a - i*n if x>0 and x not in l: l.append(x) break y=a + i*n if y>0 and not y in l: l.append(y) break else : i+=1 print(l) # Indranil Ghosh, Jun 03 2017
A005132(10)=11, so 11 is a term (and A005132(11)=22).
After we have found A005132(6)=13, we attempt to subtract 7 from 13 to get a(7). However, this would give 6, which is a collision, since we already have A005132(3)=6. So 6 gets added to the current sequence.
After we have found A005132(6)=13, we attempt to subtract 7 from 13 to get a(7). However, this would give 6, which is a collision, since we already have A005132(3)=6. So 7 gets added to the current sequence.
a(0) = 24 as a(0) corresponds to the standard Recamán's sequence A005132 in which the term 42 appears at A005132(20) and then again at A005132(24), taking twenty-four terms before the first repeated number appears. a(4) = 3 as starting from 4 the sequence of visited numbers is 4,3,1,4 and it takes three steps beyond the start value for the first repeated number 4 to appear. a(6) = 15 as starting from 6 the sequence of visited numbers is 6,5,3,0,4,9,15,8,16,7,17,28,40,27,13,28 and it takes fifteen steps beyond the start value for the first repeated number 28 to appear.
A005132(21) = 63, 63 is divisible by 21, so 21 is in the sequence.
With[{s = Nest[Append[#1, If[And[#3 > 0, FreeQ[#1, #3]], #3, #1[[-1]] + #2]] & @@ {#1, #2, #1[[-1]] - #2} & @@ {#, Length@ #} &, {0}, 10^5]}, Reap[Do[If[Mod[s[[i]], i] == 0, Sow[i]], {i, Length@ s - 1}]][[-1, -1]]] (* Michael De Vlieger, Dec 29 2019 *)
Comments