login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A230038
Distance between n^2 and the smallest triangular number >= n^2.
3
0, 2, 1, 5, 3, 0, 6, 2, 10, 5, 15, 9, 2, 14, 6, 20, 11, 1, 17, 6, 24, 12, 32, 19, 5, 27, 12, 36, 20, 3, 29, 11, 39, 20, 0, 30, 9, 41, 19, 53, 30, 6, 42, 17, 55, 29, 2, 42, 14, 56, 27, 71, 41, 10, 56, 24, 72, 39, 5, 55, 20, 72, 36, 90, 53, 15, 71, 32, 90, 50, 9, 69, 27, 89, 46, 2, 66, 21, 87, 41, 109, 62
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
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
Cf. A064784.
Sequence in context: A199660 A367671 A141483 * A277448 A177760 A329440
KEYWORD
nonn
AUTHOR
Ralf Stephan, Oct 08 2013
STATUS
approved