A386947 A variant of Recamán's sequence (A005132): a(0) = 0; for n > 0, a(n) = a(n-1) - n if nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + n + 2.
0, 3, 1, 6, 2, 9, 17, 10, 20, 11, 23, 12, 26, 13, 29, 14, 32, 15, 35, 16, 38, 61, 39, 64, 40, 67, 41, 70, 42, 73, 43, 76, 44, 79, 45, 82, 46, 85, 47, 8, 50, 93, 51, 96, 52, 7, 55, 104, 56, 107, 57, 110, 58, 5, 61, 118, 62, 121, 63, 4, 66
Offset: 0
Links
- Jules Beauchamp, The first 60 steps drawn as a spiral.
Programs
-
Mathematica
a[n_] := a[n] = If[a[n-1] >= n && FreeQ[Table[a[k], {k, 0, n-1}], a[n-1] - n], a[n-1] - n, a[n-1] + n + 2]; a[0] = 0; Array[a, 100, 0] (* Amiram Eldar, Aug 22 2025 *)
Comments