OFFSET
0,7
COMMENTS
Triangular(n) = n*(n+1)/2.
LINKS
Chai Wah Wu, Table of n, a(n) for n = 0..10000
EXAMPLE
a(7) = 6 because the least k such that triangular(n) + k^2 is a square is k=6: 7*(7+1)/2 + 6^2 = 28+36 = 64 = 8^2.
MATHEMATICA
Join[{0}, Table[k = 0; While[k < n && ! IntegerQ[Sqrt[n*(n + 1)/2 + k^2]], k++]; If[k == n, k = -1]; k, {n, 100}]] (* T. D. Noe, Nov 21 2013 *)
PROG
(Python)
from __future__ import division
from sympy import divisors
def A232178(n):
if n == 0:
return 0
t = n*(n+1)//2
ds = divisors(t)
l, m = divmod(len(ds), 2)
if m:
return 0
for i in range(l-1, -1, -1):
x = ds[i]
y = t//x
a, b = divmod(y-x, 2)
if not b:
return a
return -1 # Chai Wah Wu, Sep 12 2017
CROSSREFS
Cf. A082183 (least k>0 such that triangular(n) + triangular(k) is a triangular number).
Cf. A232177 (least k>0 such that triangular(n) + triangular(k) is a square).
Cf. A232176 (least k>0 such that n^2 + triangular(k) is a square).
Cf. A232179 (least k>=0 such that n^2 + triangular(k) is a triangular number).
Cf. A101157 (least k>0 such that triangular(n) + k^2 is a triangular number).
KEYWORD
sign
AUTHOR
Alex Ratushnyak, Nov 20 2013
STATUS
approved