login
Least positive k such that n^3 + k^2 is a square, or 0 if there is no such k.
3

%I #43 Nov 13 2024 15:02:55

%S 0,1,3,6,10,3,21,8,36,15,55,6,78,35,15,48,136,27,171,10,42,99,253,10,

%T 300,143,81,42,406,15,465,64,88,255,35,63,666,323,91,3,820,21,903,55,

%U 66,483,1081,48,1176,125,85,39,1378,81,165,28,76,783,1711,15,1830,899,63

%N Least positive k such that n^3 + k^2 is a square, or 0 if there is no such k.

%C Numbers n such that a(n) = n*(n-1)/2 appear to be A000430.

%C n = 1 is the only number for which a(n) = 0. - _T. D. Noe_, Nov 21 2013

%H Chai Wah Wu, <a href="/A232175/b232175.txt">Table of n, a(n) for n = 1..10000</a> (n = 1..1000 from T. D. Noe).

%H StackExchange, <a href="http://math.stackexchange.com/questions/112561">The cube of integer can be written as the difference of two square</a>.

%t Join[{0}, Table[k = 1; While[! IntegerQ[Sqrt[n^3 + k^2]], k++]; k, {n, 2, 100}]] (* _T. D. Noe_, Nov 21 2013 *)

%o (Python)

%o import math

%o for n in range(77):

%o n3 = n*n*n

%o y=1

%o for k in range(1, 10000001):

%o s = n3 + k*k

%o r = int(math.sqrt(s))

%o if r*r == s:

%o print(k, end=', ')

%o y=0

%o break

%o if y: print(end='-, ')

%o (Python)

%o from __future__ import division

%o from sympy import divisors

%o def A232175(n):

%o n3 = n**3

%o ds = divisors(n3)

%o for i in range(len(ds)//2-1,-1,-1):

%o x = ds[i]

%o y = n3//x

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

%o if not b:

%o return a

%o return 0 # _Chai Wah Wu_, Sep 12 2017

%o (PARI) a(n) = {k = 1; while (!issquare(n^3+k^2), k++); k;} \\ _Michel Marcus_, Nov 20 2013

%Y Cf. A000290, A000430, A000578, A038202, A055527, A232176.

%K nonn,look,changed

%O 1,3

%A _Alex Ratushnyak_, Nov 19 2013