OFFSET
1,2
COMMENTS
LINKS
Zak Seidov, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (1,2,-2,-1,1).
FORMULA
G.f. ( -x*(1+10*x+7*x^2+6*x^3) ) / ( (1+x)^2*(x-1)^3 ). - R. J. Mathar, Jan 25 2011
a(n) = 1/4*(12*n^2 - 6*n + (-1)^n*(4*n-1) + 1). - Colin Barker, Dec 26 2015
EXAMPLE
a(1) = 1^2/1 is integer. The average of the first two squares is (1^2+2^2)/2=5/2, not integer.
The average of the first three squares is (1^2+2^2+3^2)/3=14/3, not integer.
The average of the first five squares is (1^2+2^2+3^2+4^2+5^2)/ 5=11, integer, and constitutes a(2).
MATHEMATICA
s=0; lst={}; Do[a=(s+=n^2)/n; If[Mod[a, 1]==0, AppendTo[lst, a]], {n, 6!}]; lst
Flatten[Table[{(1 + 3 k) (1 + 4 k), (1 + k) (11 + 12 k)}, {k, 0, 499}]] (* Zak Seidov, Aug 15 2012 *)
Module[{nn=150, sq}, sq=Range[nn]^2; Select[Table[Mean[Take[sq, n]], {n, nn}], IntegerQ]] (* or *) LinearRecurrence[{1, 2, -2, -1, 1}, {1, 11, 20, 46, 63}, 50] (* Harvey P. Dale, Oct 31 2013 *)
PROG
(PARI) a(n) = 1/4*(12*n^2 - 6*n + (-1)^n*(4*n-1) + 1) \\ Colin Barker, Dec 26 2015
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Vladimir Joseph Stephan Orlovsky, Aug 16 2009
EXTENSIONS
Edited by R. J. Mathar, Aug 20 2009
STATUS
approved