A232178 Least k>=0 such that triangular(n) + k^2 is a square, or -1 if no such k exists.
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
Keywords
Examples
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.
Links
- Chai Wah Wu, Table of n, a(n) for n = 0..10000
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).
Programs
-
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 *)
-
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
Comments