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

Numbers n such that the distance between n^3 and the nearest square is less than n.
3

%I #23 May 05 2021 13:40:17

%S 1,2,3,4,5,9,13,15,16,17,25,32,35,36,37,40,43,46,49,52,56,63,64,65,81,

%T 99,100,101,109,121,136,143,144,145,152,158,169,175,190,195,196,197,

%U 225,243,255,256,257,289,312,317,323,324,325,331,336,351,356,361,366,377

%N Numbers n such that the distance between n^3 and the nearest square is less than n.

%C Distance can be zero, that is, cubes that are squares are included.

%C Numbers n such that A002938(n) < n.

%H Daniel Mondot, <a href="/A253181/b253181.txt">Table of n, a(n) for n = 1..10000</a>

%e The distance between 5^3=125 and the nearest square 11^2=121 is less than 5, so 5 is in the sequence.

%t dnsQ[n_]:=Module[{n3=n^3,sr},sr=Sqrt[n3];Min[n3-Floor[sr]^2, Ceiling[ sr]^2- n3]<n]; Select[Range[400],dnsQ] (* _Harvey P. Dale_, Dec 23 2015 *)

%o (Python)

%o def isqrt(a):

%o sr = 1 << (int.bit_length(int(a)) >> 1)

%o while a < sr*sr: sr>>=1

%o b = sr>>1

%o while b:

%o s = sr + b

%o if a >= s*s: sr = s

%o b>>=1

%o return sr

%o for n in range(1000):

%o cube = n*n*n

%o r = isqrt(cube)

%o sqr = r**2

%o if cube-sqr < n or sqr+2*r+1-cube < n: print(str(n), end=',')

%Y Cf. A000290, A000578, A002760.

%Y Cf. A116885, A002938, A077119.

%Y Cf. A268509, A268510.

%K nonn

%O 1,2

%A _Alex Ratushnyak_, Mar 23 2015