OFFSET
0,6
COMMENTS
For n >= 3, 0 <= a(n) <= (n - 3).
a(n) are the least solutions s (together with some k) of the Diophantine equation 1 + ... + k = (k + n) + ... + (k + n + s) for k >= 1 and s >= 0, since that becomes k = ((2*s+1) + sqrt(8*(s + 1)*(s + n) + 1)) / 2 which is an integer iff (s + 1)*(s + n) is a triangular number.
LINKS
James C. McMahon, Table of n, a(n) for n = 0..1000
Ctibor O. Zizka, Plot of n vs. a(n)
EXAMPLE
For n = 7: (s + 1)*(s + 7) is a triangular number for the least s = 4, thus a(7) = 4.
MATHEMATICA
a[n_]:=Module[{s=0}, While[!IntegerQ[(Sqrt[8*(s+1)*(s+n)+1]-1)/2], s++]; s]; Array[a, 75, 0] (* James C. McMahon, Sep 07 2025 *)
PROG
(PARI) a(n) = my(s=0); while (!ispolygonal((s + 1)*(s + n), 3), s++); s; \\ Michel Marcus, Sep 01 2025
(Python)
from sympy.abc import x, y, t
from sympy.solvers.diophantine.diophantine import diop_quadratic
def A387517(n): return min(d for d in (a[0].subs(t, 0) for a in diop_quadratic((x+1)*(x+n)*2-y*(y+1), t)) if d>=0) # Chai Wah Wu, Sep 07 2025
CROSSREFS
KEYWORD
nonn
AUTHOR
Ctibor O. Zizka, Sep 01 2025
STATUS
approved
