OFFSET
1,2
LINKS
Thomas Garrison, Table of n, a(n) for n = 1...1000
Index entries for linear recurrences with constant coefficients, signature (4,-4,-2,5,-2).
FORMULA
a(n) = 3*(2^n - 1 - n*(n+1)/2) + ceiling(n^2/2).
a(n) ~ 3*2^n.
From Stefano Spezia, Jul 10 2022: (Start)
G.f.: x*(1 - 2*x + 4*x^2 + x^3)/((1 - x)^3*(1 - x - 2*x^2)).
a(n) = (3*2^(n+2) - 4*n^2 - 6*n - 11 - (-1)^n)/4. (End)
EXAMPLE
a(5)=61: there are 3*(2^5 - 1 - binomial(6,2)) ways to select 3 or more points on a horizontal line, 5 ways on a vertical line, 3 ways on a diagonal line with slope 1, 3 ways on a diagonal line with slope -1, 1 way on a diagonal line with slope 1/2, and 1 way on a diagonal line with slope -1/2; 48 + 5 + 6 + 2 = 61.
MATHEMATICA
LinearRecurrence[{4, -4, -2, 5, -2}, {1, 2, 8, 23, 61}, 50] (* Paolo Xausa, Oct 19 2024 *)
PROG
(Python)
def a(n): return 3*((1<<n) - 1 - n*(n+1)//2)+(n**2+1)//2
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Thomas Garrison, Jul 06 2022
STATUS
approved