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 #52 Feb 21 2020 20:07:41
%S 6,8,20,24,42,48,72,80,110,120,156,168,210,224,272,288,342,360,420,
%T 440,506,528,600,624,702,728,812,840,930,960,1056,1088,1190,1224,1332,
%U 1368,1482,1520,1640,1680,1806,1848,1980,2024,2162,2208,2352,2400,2550,2600
%N Maximum remainder when (k + 1)^n + (k - 1)^n is divided by k^2 for variable n and k > 2.
%H Iain Fox, <a href="/A159469/b159469.txt">Table of n, a(n) for n = 3..10000</a>
%H Project Euler, <a href="http://projecteuler.net/index.php?section=problems&id=120">Problem 120: Square remainders</a>
%H Iain Fox, <a href="/A159469/a159469.txt">Proof for recursive definition and generating function</a>
%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (1,2,-2,-1,1).
%F maxr(n) = n*n - 2*n if n is even, and n*n - n if n is odd.
%F G.f.: x^3*(-6-2*x)/((x+1)^2*(x-1)^3). - Maksym Voznyy (voznyy(AT)mail.ru), Jul 26 2009 (proved by _Iain Fox_, Nov 26 2017)
%F a(n) = 2*A050187(n). - _R. J. Mathar_, Aug 08 2009 (proved by _Iain Fox_, Nov 27 2017)
%F a(n) = a(n-1) + 2*a(n-2) - 2*a(n-3) - a(n-4) + a(n-5) for n > 7. - _Colin Barker_, Oct 29 2017 (proved by _Iain Fox_, Nov 26 2017)
%F a(n) = n^2 - n*(3 + (-1)^n)/2. - _Iain Fox_, Nov 26 2017
%F From _Iain Fox_, Nov 27 2017: (Start)
%F a(n) = A000290(n) - A022998(n).
%F a(n) = 2*A093005(n-2) + A168273(n-1).
%F a(n) = (4*(A152749(n-2)) + A091574(n-1) - A010719(n-1))/3.
%F E.g.f.: x*(exp(x)*x - sinh(x)).
%F (End)
%e For n = 3, maxr => 3*3 - 3 = 6 since 3 is odd.
%e For n = 4, maxr => 4*4 - 2*4 = 8 since 4 is even.
%t LinearRecurrence[{1,2,-2,-1,1},{6,8,20,24,42},50] (* _Harvey P. Dale_, Apr 18 2018 *)
%o (PARI) a(n) = if (n % 2, n^2 - n, n^2 - 2*n); \\ _Michel Marcus_, Aug 26 2013
%o (PARI) first(n) = Vec(x^3*(-6-2*x)/((x+1)^2*(x-1)^3) + O(x^(n+3))) \\ _Iain Fox_, Nov 26 2017
%Y Cf. A050187.
%K nonn,easy
%O 3,1
%A _Gaurav Kumar_, Apr 13 2009