Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #19 May 14 2024 07:57:01
%S 0,2,1,-3,5,-5,7,-7,9,-9,11,-11,13,-13,15,-15,17,-17,19,-19,21,-21,23,
%T -23,25,-25,27,-27,29,-29,31,-31,33,-33,35,-35,37,-37,39,-39,41,-41,
%U 43,-43,45,-45,47,-47,49,-49,51,-51
%N a(1) = 0; thereafter a(n) is the 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. Preference is given to positive values of a(n).
%H Robert Israel, <a href="/A296064/b296064.txt">Table of n, a(n) for n = 1..10000</a>
%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (-1,1,1).
%F From _Robert Israel_, Dec 26 2017: (Start)
%F a(n) = a(n-3)+a(n-2)-a(n-1) for n >= 7.
%F G.f.: (2+3*x-4*x^2-x^3+2*x^4)*x^2/((1-x)*(x+1)^2). (End)
%F a(n) = 1/2+(-1)^n*(1/2-n), n>=4. - _R. J. Mathar_, May 14 2024
%p 0, 2, 1, -3, seq(seq(s*i,s=[1,-1]),i=5..100,2); # _Robert Israel_, Dec 26 2017
%t Nest[Append[#, Block[{k = 1, s = 1}, While[Nand[FreeQ[#, s k], IntegerQ@ Mean[Append[#, s k]]], If[s == 1, s = -1, k++; s = 1]]; s k]] &, {0}, 51] (* _Michael De Vlieger_, Dec 12 2017 *)
%Y Cf. A296065 (partial sums), A127630.
%Y Essentially the same as A296063.
%K sign,easy
%O 1,2
%A _Enrique Navarrete_, Dec 04 2017