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.

Showing 1-10 of 14 results. Next

A075052 Write down squares and cubes in order, as in A002760. The sequence gives the first differences between terms.

Original entry on oeis.org

1, 3, 4, 1, 7, 9, 2, 9, 13, 15, 17, 19, 21, 4, 19, 25, 27, 20, 9, 31, 33, 35, 19, 18, 39, 41, 43, 28, 17, 47, 49, 51, 53, 55, 57, 59, 61, 39, 24, 65, 67, 69, 71, 35, 38, 75, 77, 79, 81, 47, 36, 85, 87, 89, 91, 81, 12, 95, 97, 99, 101, 103, 40, 65, 107, 109, 111, 113, 115, 11
Offset: 1

Views

Author

Zak Seidov, Oct 07 2002

Keywords

Comments

Ordered sequence of squares and cubes is as in A002760.

Examples

			First sorted squares and cubes are: 0, 1, 4, 8, 9, 16, 25, 27, 36, 49, 64, 81, 100, hence a(1) = 1 - 0 = 1, a(10) = 64 - 49 = 15, a(12) = 100 - 81 = 19.
		

Crossrefs

Cf. A002760.

Programs

  • Mathematica
    Module[{nn=70,sq,cb},sq=Range[0,nn]^2;cb=Select[Range[nn]^3,#<=sq[[-1]]&];Join[sq,cb]//Union//Differences] (* Harvey P. Dale, Jun 11 2024 *)
  • PARI
    lista(nn) = {vec = vector(nn, i, i-1); pp = select(i->(issquare(i) || (ispower(i, 3))), vec); for (i=1, #pp-1, print1(pp[i+1] - pp[i], ", "););} \\ Michel Marcus, Oct 03 2013
    
  • Python
    from math import isqrt
    from sympy import integer_nthroot
    def A075052(n):
        def f(x): return n-1+x+integer_nthroot(x,6)[0]-(b:=integer_nthroot(x,3)[0])-(a:=isqrt(x)), a, b
        m = n-1
        k, a, b = f(n-1)
        while m != k:
            m = k
            k, a, b = f(k)
        return min((a+1)**2,(b+1)**3)-m # Chai Wah Wu, Aug 09 2024

Formula

a(n) = A002760(n+1) - A002760(n).

A374754 a(n) is the difference between the sum of the squares and the sum of the cubes for the n first terms of A002760.

Original entry on oeis.org

0, 0, 4, -4, 5, 21, 46, 19, 55, 104, 104, 185, 285, 406, 281, 425, 594, 790, 574, 799, 1055, 1344, 1668, 1325, 1686, 2086, 2527, 3011, 2499, 3028, 3604, 4229, 4905, 4905, 5689, 6530, 7430, 8391, 7391, 8415, 9504, 10660, 11885, 13181, 11850, 13219, 14663, 16184
Offset: 1

Views

Author

Felix Huber, Jul 28 2024

Keywords

Comments

For A002760(n) <= k < A002760(n+1), the difference between the sum of the squares and the sum of the cubes in the first k nonnegative integers is a(n).

Examples

			a(7) = a(6) + A002760(7) = 21 + 1*25 = 46, since 25 is a square but not a cube.
a(8) = a(7) - A002760(8) = 46 + (-1)*27 = 19, since 27 is a cube but not a square.
a(11) = a(10) + A002760(11) - A002760(11) = 104 + 0*64 = 104, since 64 is a square and a cube.
The difference between the sum of the squares and the sum of the cubes in the first 24 nonnegative integers is a(6) = 21, because A002760(6) = 16 <= 24 < A002760(7) = 25.
		

Crossrefs

Cf. A000330 (sum of squares), A000537 (sum of cubes), A001014 (sixth powers), A002760 (squares and cubes), A061023, A087285, A087286.

Programs

  • Maple
    isA374754:=proc(k)
       option remember;
       if k=0 then 0
       elif issqr(k) and not type(root(k,3),integer) then procname(k-1)+k;
       elif type(root(k,3),integer) and not issqr(k) then procname(k-1)-k;
       else procname(k-1)
       fi;
    end proc;
    A374754:=k->
       if k=0 then 0
       elif isA374754(k)<>isA374754(k-1) or type(root(k,6),integer) then isA374754(k)
       fi;
    seq(A374754(k),k=0..1521);
  • PARI
    lista(nn) = my(v = select(x->issquare(x) || ispower(x, 3), [0..nn]), s=0, w = vector(#v)); for (i=1, #v, if (issquare(v[i]), s += v[i]); if (ispower(v[i], 3), s -= v[i]); w[i] = s;); w; \\ Michel Marcus, Aug 04 2024
    
  • Python
    from math import isqrt
    from sympy import integer_nthroot
    def A374754(n):
        def f(x): return n-1+x+integer_nthroot(x,6)[0]-(b:=integer_nthroot(x,3)[0])-(a:=isqrt(x)), a, b
        m = n-1
        k, a, b = f(n-1)
        while m != k:
            m = k
            k, a, b = f(k)
        return a*(a+1)*((a<<1)+1)//3-((b*(b+1))**2>>1)>>1 # Chai Wah Wu, Aug 09 2024

Formula

a(1) = 0. For n >= 2, a(n) = a(n-1) + f*A002760(n) where f = 1 if A002760(n) is a square but not a cube, f = -1 if A002760(n) is a cube but not a square and f = 0 if A002760(n) is a square and a cube.

A022549 Sum of a square and a nonnegative cube.

Original entry on oeis.org

0, 1, 2, 4, 5, 8, 9, 10, 12, 16, 17, 24, 25, 26, 27, 28, 31, 33, 36, 37, 43, 44, 49, 50, 52, 57, 63, 64, 65, 68, 72, 73, 76, 80, 81, 82, 89, 91, 100, 101, 108, 113, 121, 122, 125, 126, 127, 128, 129, 134, 141, 144, 145
Offset: 1

Views

Author

Keywords

Comments

It appears that there are no modular constraints on this sequence; i.e., every residue class of every integer has representatives here. - Franklin T. Adams-Watters, Dec 03 2009
A045634(a(n)) > 0. - Reinhard Zumkeller, Jul 17 2010

Crossrefs

Complement of A022550; A002760 and A179509 are subsequences.

Programs

  • Mathematica
    q=30; imax=q^2; Select[Union[Flatten[Table[x^2+y^3, {y,0,q^(2/3)}, {x,0,q}]]], #<=imax&] (* Vladimir Joseph Stephan Orlovsky, Apr 20 2011 *)
  • PARI
    is(n)=for(k=0,sqrtnint(n,3), if(issquare(n-k^3), return(1))); 0 \\ Charles R Greathouse IV, Aug 24 2020
    
  • PARI
    list(lim)=my(v=List(),t); for(k=0,sqrtnint(lim\=1,3), t=k^3; for(n=0,sqrtint(lim-t), listput(v,t+n^2))); Set(v) \\ Charles R Greathouse IV, Aug 24 2020

A077110 Nearest integer cube to n^2.

Original entry on oeis.org

0, 1, 1, 8, 8, 27, 27, 64, 64, 64, 125, 125, 125, 125, 216, 216, 216, 343, 343, 343, 343, 512, 512, 512, 512, 729, 729, 729, 729, 729, 1000, 1000, 1000, 1000, 1000, 1331, 1331, 1331, 1331, 1331, 1728, 1728, 1728, 1728, 1728, 2197, 2197, 2197
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 29 2002

Keywords

Examples

			a(10) = 125, as 125 = 5^3 is the nearest cube to 100 = 10^2.
		

Crossrefs

Cf. A002760 (Squares and cubes). - Zak Seidov, Oct 08 2015

Programs

  • Mathematica
    nic[n_]:=Module[{n2=n^2,s3,c1,c2},s3=Surd[n2,3];c1=Floor[s3]^3;c2= Ceiling[ s3]^3;If[n2-c1Harvey P. Dale, Jul 05 2015 *)
  • Python
    from sympy import integer_nthroot
    def A077110(n):
        n2 = n**2
        a = integer_nthroot(n2,3)[0]
        a2, a3 = a**3, (a+1)**3
        return a3 if a3+a2-2*n2 < 0 else a2 # Chai Wah Wu, Sep 24 2021

Formula

a(n) = if A075847(n) < A070923(n) then A077106(n) else A077107(n).

A131799 Number of partitions of n into parts that are squares or cubes.

Original entry on oeis.org

1, 1, 1, 1, 2, 2, 2, 2, 4, 5, 5, 5, 7, 8, 8, 8, 12, 14, 15, 15, 19, 21, 22, 22, 28, 33, 35, 37, 43, 48, 50, 52, 61, 69, 74, 78, 90, 98, 103, 107, 122, 135, 143, 152, 170, 186, 194, 203, 225, 247, 261, 275, 305, 330, 348, 362, 396, 429, 454, 477, 519, 561, 590, 618, 666, 717
Offset: 0

Views

Author

Reinhard Zumkeller, Jul 16 2007

Keywords

Comments

a(n) = A078635(n) for n < 32 = 2^5.

Examples

			a(10) = #{9+1, 8+1+1, 4+4+1+1, 4+1+1+1+1+1+1, 1+1+1+1+1+1+1+1+1+1} = 5.
		

Crossrefs

Programs

  • Mathematica
    nmax = 65; c2max = nmax^(1/2); c3max = nmax^(1/3);
    s = Flatten[{Table[n^2, {n, 1, c2max}]}~Join~{Table[n^3, {n, 1, c3max}]}];
    Table[Count[IntegerPartitions@n, x_ /; SubsetQ[s, x]], {n, 0, nmax}] (* Robert Price, Jul 31 2020 *)

Formula

G.f.: Product_{k>=1} (1 - x^(k^6)) / ((1 - x^(k^2)) * (1 - x^(k^3))). - Vaclav Kotesovec, Jan 12 2017

Extensions

a(0)=1 prepended by Ilya Gutkovskiy, Jan 11 2017

A087797 Primes, squares of primes and cubes of primes.

Original entry on oeis.org

2, 3, 4, 5, 7, 8, 9, 11, 13, 17, 19, 23, 25, 27, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 121, 125, 127, 131, 137, 139, 149, 151, 157, 163, 167, 169, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241
Offset: 1

Views

Author

Benoit Cloitre, Oct 10 2003

Keywords

Comments

Union of A000040 and A168363. - Chai Wah Wu, Aug 09 2024

Crossrefs

Programs

  • Mathematica
    m=400;Union[Prime[Range[PrimePi[m]]],Prime[Range[PrimePi[m^(1/2)]]]^2,Prime[Range[PrimePi[m^(1/3)]]]^3] (* Vladimir Joseph Stephan Orlovsky, Apr 11 2011 *)
    With[{nn=70},Take[Union[Flatten[{#,#^2,#^3}&/@Prime[Range[nn]]]],nn]] (* Harvey P. Dale, Oct 16 2012 *)
  • PARI
    is(n)=my(t=isprimepower(n)); t && t<4 \\ Charles R Greathouse IV, Oct 19 2015
    
  • Python
    from math import isqrt
    from sympy import primepi, integer_nthroot
    def A087797(n):
        def f(x): return n+x-primepi(x)-primepi(isqrt(x))-primepi(integer_nthroot(x,3)[0])
        m, k = n, f(n)
        while m != k:
            m, k = k, f(k)
        return int(m) # Chai Wah Wu, Aug 09 2024

Formula

a(n) ~ n log n. - Charles R Greathouse IV, Oct 19 2015

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)
    

A377025 Squares and cubes that are not 6th powers.

Original entry on oeis.org

4, 8, 9, 16, 25, 27, 36, 49, 81, 100, 121, 125, 144, 169, 196, 216, 225, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 784, 841, 900, 961, 1000, 1024, 1089, 1156, 1225, 1296, 1331, 1369, 1444, 1521, 1600, 1681, 1728, 1764, 1849, 1936, 2025
Offset: 1

Views

Author

Chai Wah Wu, Oct 13 2024

Keywords

Comments

Squares and cubes that cannot be written as both a square and a cube.
A125643 minus the repeated terms.

Crossrefs

Programs

  • Mathematica
    lim=2025;Select[Union[Range[Floor[lim^(1/2)]]^2,Range[Floor[lim^(1/3)]]^3],!IntegerQ[#^(1/6)]&] (* James C. McMahon, Oct 16 2024 *)
  • Python
    from math import isqrt
    from sympy import integer_nthroot
    def A377025(n):
        def bisection(f,kmin=0,kmax=1):
            while f(kmax) > kmax: kmax <<= 1
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                if f(kmid) <= kmid:
                    kmax = kmid
                else:
                    kmin = kmid
            return kmax
        def f(x): return n+x+(integer_nthroot(x,6)[0]<<1)-integer_nthroot(x,3)[0]-isqrt(x)
        return bisection(f,n,n)

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

Original entry on oeis.org

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, 99, 100, 101, 109, 121, 136, 143, 144, 145, 152, 158, 169, 175, 190, 195, 196, 197, 225, 243, 255, 256, 257, 289, 312, 317, 323, 324, 325, 331, 336, 351, 356, 361, 366, 377
Offset: 1

Views

Author

Alex Ratushnyak, Mar 23 2015

Keywords

Comments

Distance can be zero, that is, cubes that are squares are included.
Numbers n such that A002938(n) < n.

Examples

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

Crossrefs

Programs

  • Mathematica
    dnsQ[n_]:=Module[{n3=n^3,sr},sr=Sqrt[n3];Min[n3-Floor[sr]^2, Ceiling[ sr]^2- n3]Harvey P. Dale, Dec 23 2015 *)
  • 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
    for n in range(1000):
        cube = n*n*n
        r = isqrt(cube)
        sqr = r**2
        if cube-sqr < n or sqr+2*r+1-cube < n:  print(str(n), end=',')

A125643 Squares and cubes (with repetition).

Original entry on oeis.org

0, 0, 1, 1, 4, 8, 9, 16, 25, 27, 36, 49, 64, 64, 81, 100, 121, 125, 144, 169, 196, 216, 225, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 729, 784, 841, 900, 961, 1000, 1024, 1089, 1156, 1225, 1296, 1331, 1369, 1444, 1521, 1600, 1681
Offset: 1

Views

Author

Zak Seidov, Oct 19 2006

Keywords

Comments

Repeating terms are sixth powers: 0,1,64,729,... (A001014).
For numbers not appearing as a difference between a square and an adjacent cube in this list, see A054504 and A081121.

Crossrefs

Cf. A002760 (squares and cubes (without repetitions)).

Programs

  • Mathematica
    m=1681;cm=Floor[m^(1/3)];sm=Floor[Sqrt[m]];s=Range[0,sm]^2;c=Range[0,cm]^3;Sort[Join[s,c]] (* James C. McMahon, Dec 20 2024 *)
  • Python
    from math import isqrt
    from sympy import integer_nthroot
    def A125643(n):
        if n <= 4: return n-1>>1
        def bisection(f,kmin=0,kmax=1):
            while f(kmax) > kmax: kmax <<= 1
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                if f(kmid) <= kmid:
                    kmax = kmid
                else:
                    kmin = kmid
            return kmax
        def f(x): return n-2+x-integer_nthroot(x,3)[0]-isqrt(x)
        return bisection(f,n-2,n-2) # Chai Wah Wu, Oct 14 2024

Extensions

Edited by N. J. A. Sloane at the suggestion of Andrew S. Plewe, Jul 14 2007
Showing 1-10 of 14 results. Next