A257909 Sequence (d(n)) generated by Rule 3 (in Comments) with a(1) = 0 and d(1) = 2.
2, 1, 3, -2, 4, -3, 5, -1, 8, -10, 6, 12, -14, 10, -9, 11, -8, 14, -15, 13, -11, 15, -13, 17, -16, 18, -17, 19, -7, -6, -4, 21, -19, 23, -5, -12, 29, -31, 27, -22, 32, -29, 35, -37, 33, -27, 39, -41, 37, -34, 40, -36, 44, -45, 43, -39, 47, -49, 45, -42, 48
Offset: 1
Examples
a(1) = 0, d(1) = 2; a(2) = 1, d(2) = 1; a(3) = 4, d(3) = 3; a(4) = 2, d(4) = -2.
Links
- Clark Kimberling, Table of n, a(n) for n = 1..1000
Programs
-
Mathematica
{a, f} = {{0}, {2}}; Do[tmp = {#, # - Last[a]} &[Min[Complement[#, Intersection[a, #]]&[Last[a] + Complement[#, Intersection[f, #]] &[Range[2 - Last[a], -1]]]]]; If[! IntegerQ[tmp[[1]]], tmp = {Last[a] + #, #} &[NestWhile[# + 1 &, 1, ! (! MemberQ[f, #] && ! MemberQ[a, Last[a] - #]) &]]]; AppendTo[a, tmp[[1]]]; AppendTo[f, tmp[[2]]], {120}]; {a, f} (* Peter J. C. Moses, May 14 2015 *)
Comments