OFFSET
1,2
LINKS
Andrew Howroyd, Table of n, a(n) for n = 1..1000
Eric Weisstein's World of Mathematics, Longest Path.
Eric Weisstein's World of Mathematics, Stacked Book Graph.
Index entries for linear recurrences with constant coefficients, signature (2,0,-2,1).
FORMULA
From Andrew Howroyd, Feb 12 2026: (Start)
a(n) = n^2 + 1 - 2*floor((n-2)/2)*floor((n-3)/2) for n > 1.
a(n) = (2*n^2 + 12*n - 13 + (-1)^n)/4 for n > 1.
G.f.: x*(1 + 3*x - x^3 - x^4)/((1 - x)^3*(1 + x)). (End)
MATHEMATICA
LinearRecurrence[{2, 0, -2, 1}, {1, 5, 10, 17, 24}, 60] (* Paolo Xausa, Mar 31 2026 *)
PROG
(PARI) a(n) = if(n==1, 1, n^2 + 1 - if(n%2, (n-3)^2, (n-4)*(n-2))/2) \\ Andrew Howroyd, Feb 12 2026
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Eric W. Weisstein, Mar 20 2019
EXTENSIONS
a(8) from Eric W. Weisstein, Apr 09 2019
a(9) onward from Andrew Howroyd, Feb 12 2026
STATUS
approved
