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”).

A232178
Least k>=0 such that triangular(n) + k^2 is a square, or -1 if no such k exists.
4
0, 0, 1, -1, -1, 1, 2, 6, 0, 2, 3, -1, -1, 3, 4, 1, 15, 4, 5, -1, -1, 5, 6, 20, 10, 6, 7, -1, -1, 7, 8, 27, 1, 8, 9, -1, -1, 9, 10, 2, 36, 10, 11, -1, -1, 11, 12, 41, 7, 0, 13, -1, -1, 13, 6, 24, 2, 14, 15, -1, -1, 15, 16, 3, 6, 8, 17, -1, -1, 17, 18, 62, 64, 18, 19
OFFSET
0,7
COMMENTS
Triangular(n) = n*(n+1)/2.
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).
Sequence in context: A072340 A118354 A080730 * A016590 A079461 A220233
KEYWORD
sign
AUTHOR
Alex Ratushnyak, Nov 20 2013
STATUS
approved