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.
LINKS
Robert Israel, Table of n, a(n) for n = 3..10000
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.
MAPLE
f:= proc(n) local t, alpha, beta;
t:= n^2-n;
alpha:= convert(select(type, numtheory:-divisors(t), odd), list);
beta:= map(s -> (s+t/s - 1)/2 - n, alpha);
min(select(`>=`, beta, 0))
end proc:
map(f, [$3..100]); # Robert Israel, Jan 30 2025
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,look
AUTHOR
Ctibor O. Zizka, Dec 30 2024
STATUS
approved
