login
Numbers that are midway between the nearest square and the nearest cube.
4

%I #48 May 07 2021 09:10:13

%S 6,26,123,206,352,498,1012,1350,1746,2203,2724,3428,4977,5804,6874,

%T 8050,9335,10732,12244,13874,17500,19782,21928,24519,26948,29860,

%U 32946,35829,39254,42862,50639,54814,59184,63752,69045,74036,79234,85224,90863,97340,104076

%N Numbers that are midway between the nearest square and the nearest cube.

%C The sequence of roots of nearest squares begins: 2, 5, 11, 14, 19, 22, 32, 37, 42, 47, 52, 59, 71, 76, 83, 90, 97, 104, 111, 118, 132, ...

%C The sequence of cube roots of nearest cubes begins: 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 26, ... (Cf. A000037)

%C The sequence of k-k2 (equals k3-k) begins: 2, 1, 2, 10, -9, 14, -12, -19, -18, -6, 20, -53, -64, 28, -15, -50, -74, -84, -77, -50, ...

%C If we allow k2=k3 then first missing terms are 0, 1, 64, 729, 4096, ... . - _Zak Seidov_, Dec 10 2013

%H Zak Seidov and Charles R Greathouse IV, <a href="/A233075/b233075.txt">Table of n, a(n) for n = 1..10000</a> (first 2108 from Seidov)

%e 26 = 5^2 + 1 = 3^3 - 1.

%e 352 = 19^2 - 9 = 7^3 + 9.

%t max = 10^6; u = Union[Range[Ceiling[Sqrt[max]]]^2,Range[Ceiling[ max^(1/3) ]]^3]; Reap[Do[x = u[[k]]; y = u[[k+1]]; If[Not[IntegerQ[Sqrt[x]] && IntegerQ[Sqrt[y]]] && Not[IntegerQ[x^(1/3)] && IntegerQ[y^(1/3)]] && IntegerQ[m = (x+y)/2], Sow[m]], {k, 1, Length[u]-2}]][[2, 1]] (* _Jean-François Alcover_, Dec 03 2015 *)

%t Module[{upto=150000,nns},nns=Union[Join[Range[Floor[Sqrt[upto]]]^2,Range[Floor[Surd[upto,3]]]^3]];Mean/@Select[Partition[nns,2,1],EvenQ[Total[#]]&]] (* _Harvey P. Dale_, Nov 06 2017 *)

%o (Java)

%o import java.math.*;

%o public class A233075 {

%o public static void main (String[] args) {

%o for (long k = 1; ; k++) { // ok for small k's

%o long r2=(long)Math.sqrt(k), r3=(long)Math.cbrt(k);

%o long b2=r2*r2, a2=b2+r2*2+1; //squares below and above

%o long b3=r3*r3*r3, a3=b3+3*r3*(r3+1)+1; //cubes below, above

%o if ((b2+a3==k*2 && k-b2<=a2-k && a3-k<=k-b3) ||

%o (b3+a2==k*2 && k-b3<=a3-k && a2-k<=k-b2))

%o System.out.printf("%d, ", k);

%o }

%o }

%o }

%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 a=[]

%o for c in range(1, 10000):

%o cube = c*c*c

%o srB = isqrt(cube)

%o srB2= srB**2

%o if srB2==cube: continue

%o if ((srB2^cube)&1)==0:

%o n = (srB2+cube)//2

%o else:

%o n = (srB2+2*srB+1+cube)//2

%o a.append(n)

%o print(a)

%o (PARI) list(lim)=my(v=List(),m=2,n=2,m2=4,n3=8,s=12); lim*=2; while(s <= lim, if(s%2==0 && m2!=n3 && abs(s/2-m2)<=abs(s/2-(m-1)^2) && abs(s/2-m2)<=abs(s/2-(m+1)^2) && abs(s/2-m2)<=abs(s/2-(n-1)^3) && abs(s/2-m2)<=abs(s/2-(n+1)^3), listput(v,s/2)); if(m2<n3, m2=m++^2, m2>n3, n3=n++^3, m2=m++^2; n3=n++^3); s=m2+n3); Vec(v) \\ _Charles R Greathouse IV_, Jul 29 2016

%Y Cf. A000290, A000578, A075454, A233074.

%Y Cf. A002760 (Squares and cubes).

%Y Cf. A001014 (Additional terms if k2=k3 were allowed).

%K nonn,nice,easy

%O 1,1

%A _Alex Ratushnyak_, Dec 03 2013