A293835 a(n) = smallest number (in absolute value) not yet in the sequence such that the arithmetic mean of the first n terms a(1), a(2), ..., a(n) is an integer; a(1)=1. No two numbers with the same absolute value may appear. Preference is given to positive values of a(n).
1, 3, 2, 6, -7, -5, 0, 8, 10, 12, 14, 4, -9, -11, -13, -15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 16, -18, -20, -22, -24, -26, -28, -30, -32, -34, -36, -38, -40, -42, -44, -46, -48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78
Offset: 1
Examples
For n=7: (1 + 3 + 2 + 6 - 7 - 5 + 0)/7 is an integer.
Links
- Enrique Navarrete, Table of n, a(n) for n = 1..64
Programs
-
Mathematica
a[1] = 1; a[n_] := a[n] = For[k = 0, True, k++, aa = Array[a, n - 1]; If[FreeQ[aa, k | -k], If[IntegerQ[Mean[Append[aa, k]]], Return[k]]; If[IntegerQ[Mean[Append[aa, -k]]], Return[-k]]]]; Array[a, 100] (* Jean-François Alcover, Dec 09 2017 *)
Comments