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.
%I A374754 #34 Aug 10 2024 21:39:33 %S A374754 0,0,4,-4,5,21,46,19,55,104,104,185,285,406,281,425,594,790,574,799, %T A374754 1055,1344,1668,1325,1686,2086,2527,3011,2499,3028,3604,4229,4905, %U A374754 4905,5689,6530,7430,8391,7391,8415,9504,10660,11885,13181,11850,13219,14663,16184 %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. %C A374754 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). %H A374754 Felix Huber, <a href="/A374754/b374754.txt">Table of n, a(n) for n = 1..10000</a> %F A374754 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. %e A374754 a(7) = a(6) + A002760(7) = 21 + 1*25 = 46, since 25 is a square but not a cube. %e A374754 a(8) = a(7) - A002760(8) = 46 + (-1)*27 = 19, since 27 is a cube but not a square. %e A374754 a(11) = a(10) + A002760(11) - A002760(11) = 104 + 0*64 = 104, since 64 is a square and a cube. %e A374754 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. %p A374754 isA374754:=proc(k) %p A374754 option remember; %p A374754 if k=0 then 0 %p A374754 elif issqr(k) and not type(root(k,3),integer) then procname(k-1)+k; %p A374754 elif type(root(k,3),integer) and not issqr(k) then procname(k-1)-k; %p A374754 else procname(k-1) %p A374754 fi; %p A374754 end proc; %p A374754 A374754:=k-> %p A374754 if k=0 then 0 %p A374754 elif isA374754(k)<>isA374754(k-1) or type(root(k,6),integer) then isA374754(k) %p A374754 fi; %p A374754 seq(A374754(k),k=0..1521); %o A374754 (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 %o A374754 (Python) %o A374754 from math import isqrt %o A374754 from sympy import integer_nthroot %o A374754 def A374754(n): %o A374754 def f(x): return n-1+x+integer_nthroot(x,6)[0]-(b:=integer_nthroot(x,3)[0])-(a:=isqrt(x)), a, b %o A374754 m = n-1 %o A374754 k, a, b = f(n-1) %o A374754 while m != k: %o A374754 m = k %o A374754 k, a, b = f(k) %o A374754 return a*(a+1)*((a<<1)+1)//3-((b*(b+1))**2>>1)>>1 # _Chai Wah Wu_, Aug 09 2024 %Y A374754 Cf. A000330 (sum of squares), A000537 (sum of cubes), A001014 (sixth powers), A002760 (squares and cubes), A061023, A087285, A087286. %K A374754 sign %O A374754 1,3 %A A374754 _Felix Huber_, Jul 28 2024