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.

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.