OFFSET
3,2
COMMENTS
Also for n >= 3, a(n) is the least k >= 0 such that the Sum_{i = 0..k} (n + i) is a triangular number (A000217). For n = 0, 1 the Sum is a triangular number for all n. For n = 2, there is no solution.
EXAMPLE
n = 4: the least k >= 0 such that (k + 1)*(8 + k)/2 is a triangular number is k = 2, thus a(4) = 2.
n = 6: the least k >= 0 such that (k + 1)*(12 + k)/2 is a triangular number is k = 0, thus a(6) = 0.
MATHEMATICA
a[n_] := Module[{k = 0}, While[! IntegerQ[Sqrt[4*(k + 1)*(2*n + k) + 1]], k++]; k]; Array[a, 100, 3] (* Amiram Eldar, Dec 30 2024 *)
PROG
(PARI) a(n) = my(k=0); while (!ispolygonal((k + 1)*(2*n + k)/2, 3), k++); k; \\ Michel Marcus, Dec 30 2024
CROSSREFS
KEYWORD
nonn,new
AUTHOR
Ctibor O. Zizka, Dec 30 2024
STATUS
approved