A233075 Numbers that are midway between the nearest square and the nearest cube.
6, 26, 123, 206, 352, 498, 1012, 1350, 1746, 2203, 2724, 3428, 4977, 5804, 6874, 8050, 9335, 10732, 12244, 13874, 17500, 19782, 21928, 24519, 26948, 29860, 32946, 35829, 39254, 42862, 50639, 54814, 59184, 63752, 69045, 74036, 79234, 85224, 90863, 97340, 104076
Offset: 1
Examples
26 = 5^2 + 1 = 3^3 - 1. 352 = 19^2 - 9 = 7^3 + 9.
Links
- Zak Seidov and Charles R Greathouse IV, Table of n, a(n) for n = 1..10000 (first 2108 from Seidov)
Crossrefs
Programs
-
Java
import java.math.*; public class A233075 { public static void main (String[] args) { for (long k = 1; ; k++) { // ok for small k's long r2=(long)Math.sqrt(k), r3=(long)Math.cbrt(k); long b2=r2*r2, a2=b2+r2*2+1; //squares below and above long b3=r3*r3*r3, a3=b3+3*r3*(r3+1)+1; //cubes below, above if ((b2+a3==k*2 && k-b2<=a2-k && a3-k<=k-b3) || (b3+a2==k*2 && k-b3<=a3-k && a2-k<=k-b2)) System.out.printf("%d, ", k); } } }
-
Mathematica
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 *) 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 *)
-
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, n3=n++^3, m2=m++^2; n3=n++^3); s=m2+n3); Vec(v) \\ Charles R Greathouse IV, Jul 29 2016 -
Python
def isqrt(a): sr = 1 << (int.bit_length(int(a)) >> 1) while a < sr*sr: sr>>=1 b = sr>>1 while b: s = sr + b if a >= s*s: sr = s b>>=1 return sr a=[] for c in range(1, 10000): cube = c*c*c srB = isqrt(cube) srB2= srB**2 if srB2==cube: continue if ((srB2^cube)&1)==0: n = (srB2+cube)//2 else: n = (srB2+2*srB+1+cube)//2 a.append(n) print(a)
Comments