OFFSET
1,2
COMMENTS
Smallest positive Z such that x^2 + x - 2n^2 - 2Z = 0 has a solution in integer x.
a(A077241(m)) = 2.
Apparently, a(n) is triangular itself if n is of form (2k+1)*A001109(m), whenever k < A003499(m), or m > some small constant, k >= 0 (see A230060). [Comment improved by Nathaniel Johnston, Oct 08 2013]
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
EXAMPLE
The smallest triangular number >= 7^2 is 55 and 55-49=6, so a(7)=6.
MAPLE
a := proc(n) local t: t := ceil((sqrt(1 + 8*n^2) - 1)/2): return t*(t+1)/2 - n^2: end proc: seq(a(n), n=1..100); # Nathaniel Johnston, Oct 08 2013
MATHEMATICA
Module[{nn=200, tr}, tr=Accumulate[Range[nn]]; Table[SelectFirst[tr, #>=n^2&]-n^2, {n, Floor[Sqrt[tr[[-1]]]]}]] (* Harvey P. Dale, Sep 17 2022 *)
PROG
(PARI) a(n)=t=floor((sqrt(8*n^2)-1)/2)+1; t*(t+1)/2-n^2
CROSSREFS
KEYWORD
nonn
AUTHOR
Ralf Stephan, Oct 08 2013
STATUS
approved