OFFSET
3,1
LINKS
Iain Fox, Table of n, a(n) for n = 3..10000
Project Euler, Problem 120: Square remainders
Index entries for linear recurrences with constant coefficients, signature (1,2,-2,-1,1).
FORMULA
maxr(n) = n*n - 2*n if n is even, and n*n - n if n is odd.
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)
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)
a(n) = n^2 - n*(3 + (-1)^n)/2. - Iain Fox, Nov 26 2017
From Iain Fox, Nov 27 2017: (Start)
E.g.f.: x*(exp(x)*x - sinh(x)).
(End)
EXAMPLE
For n = 3, maxr => 3*3 - 3 = 6 since 3 is odd.
For n = 4, maxr => 4*4 - 2*4 = 8 since 4 is even.
MATHEMATICA
LinearRecurrence[{1, 2, -2, -1, 1}, {6, 8, 20, 24, 42}, 50] (* Harvey P. Dale, Apr 18 2018 *)
PROG
(PARI) a(n) = if (n % 2, n^2 - n, n^2 - 2*n); \\ Michel Marcus, Aug 26 2013
(PARI) first(n) = Vec(x^3*(-6-2*x)/((x+1)^2*(x-1)^3) + O(x^(n+3))) \\ Iain Fox, Nov 26 2017
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Gaurav Kumar, Apr 13 2009
STATUS
approved