cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A233075 Numbers that are midway between the nearest square and the nearest cube.

Original entry on oeis.org

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

Views

Author

Alex Ratushnyak, Dec 03 2013

Keywords

Comments

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, ...
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)
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, ...
If we allow k2=k3 then first missing terms are 0, 1, 64, 729, 4096, ... . - Zak Seidov, Dec 10 2013

Examples

			26 = 5^2 + 1 = 3^3 - 1.
352 = 19^2 - 9 = 7^3 + 9.
		

Crossrefs

Cf. A002760 (Squares and cubes).
Cf. A001014 (Additional terms if k2=k3 were allowed).

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(m2n3, 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)