login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A232178 Least k>=0 such that triangular(n) + k^2 is a square, or -1 if no such k exists. 4

%I #13 Sep 15 2017 03:20:00

%S 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,

%T 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,

%U 24,2,14,15,-1,-1,15,16,3,6,8,17,-1,-1,17,18,62,64,18,19

%N Least k>=0 such that triangular(n) + k^2 is a square, or -1 if no such k exists.

%C Triangular(n) = n*(n+1)/2.

%H Chai Wah Wu, <a href="/A232178/b232178.txt">Table of n, a(n) for n = 0..10000</a>

%e 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.

%t 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 *)

%o (Python)

%o from __future__ import division

%o from sympy import divisors

%o def A232178(n):

%o if n == 0:

%o return 0

%o t = n*(n+1)//2

%o ds = divisors(t)

%o l, m = divmod(len(ds),2)

%o if m:

%o return 0

%o for i in range(l-1,-1,-1):

%o x = ds[i]

%o y = t//x

%o a, b = divmod(y-x,2)

%o if not b:

%o return a

%o return -1 # _Chai Wah Wu_, Sep 12 2017

%Y Cf. A000217, A000290.

%Y Cf. A082183 (least k>0 such that triangular(n) + triangular(k) is a triangular number).

%Y Cf. A232177 (least k>0 such that triangular(n) + triangular(k) is a square).

%Y Cf. A232176 (least k>0 such that n^2 + triangular(k) is a square).

%Y Cf. A232179 (least k>=0 such that n^2 + triangular(k) is a triangular number).

%Y Cf. A101157 (least k>0 such that triangular(n) + k^2 is a triangular number).

%K sign

%O 0,7

%A _Alex Ratushnyak_, Nov 20 2013

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 28 07:20 EDT 2024. Contains 371235 sequences. (Running on oeis4.)