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-4 of 4 results.

A053187 Square nearest to n.

Original entry on oeis.org

0, 1, 1, 4, 4, 4, 4, 9, 9, 9, 9, 9, 9, 16, 16, 16, 16, 16, 16, 16, 16, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
Offset: 0

Views

Author

Henry Bottomley, Mar 01 2000

Keywords

Comments

Apart from 0, k^2 appears 2k times from a(k^2-k+1) through to a(k^2+k) inclusive.

Examples

			a(7) = 9 since 7 is closer to 9 than to 4.
G.f. = x + x^2 + 4*x^3 + 4*x^4 + 4*x^5 + 4*x^6 + 9*x^7 + 9*x^8 + 9*x^9 + ...
		

Crossrefs

Cf. A061023, A201053 (nearest cube), A000290, A000194.

Programs

  • Haskell
    a053187 n = a053187_list !! n
    a053187_list = 0 : concatMap (\x -> replicate (2*x) (x ^ 2)) [1..]
    -- Reinhard Zumkeller, Nov 28 2011
    
  • Maple
    seq(ceil((-1+sqrt(4*n+1))/2)^2, n=0..20); # Robert Israel, Jan 05 2015
  • Mathematica
    nearestSq[n_] := Block[{a = Floor@ Sqrt@ n}, If[a^2 + a + 1/2 > n, a^2, a^2 + 2 a + 1]]; Array[ nearestSq, 75, 0] (* Robert G. Wilson v, Aug 01 2014 *)
  • Python
    from math import isqrt
    def A053187(n): return ((m:=isqrt(n))+int(n>m*(m+1)))**2 # Chai Wah Wu, Jun 06 2025

Formula

a(n) = ceiling((-1 + sqrt(4*n+1))/2)^2. - Robert Israel, Aug 01 2014
G.f.: (1/(1-x))*Sum_{n>=0} (2*n+1)*x^(n^2+n+1). - Robert Israel, Aug 01 2014. This is related to the Jacobi theta-function theta'_1(q), see A002483 and A245552.
G.f.: x / (1-x) * Sum_{k>0} (2*k - 1) * x^(k^2 - k). - Michael Somos, Jan 05 2015
a(n) = floor(sqrt(n)+1/2)^2. - Mikael Aaltonen, Jan 17 2015
Sum_{n>=1} 1/a(n)^2 = 2*zeta(3). - Amiram Eldar, Aug 15 2022
a(n) = A000194(n)^2. - Chai Wah Wu, Jun 06 2025

Extensions

Title improved by Jon E. Schoenfield, Jun 09 2019

A201053 Nearest cube.

Original entry on oeis.org

0, 1, 1, 1, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
Offset: 0

Views

Author

Reinhard Zumkeller, Nov 28 2011

Keywords

Comments

a(n) = if n-A048763(n) < A048762(n)-n then A048762(n) else A048763(n);
apart from 0, k^3 occurs 3*n^2+1 times, cf. A056107.

Crossrefs

Cf. A061023, A074989, A053187 (nearest square), A000578.

Programs

  • Haskell
    a201053 n = a201053_list !! n
    a201053_list = 0 : concatMap (\x -> replicate (a056107 x) (x ^ 3)) [1..]
    
  • Maple
    seq(k^3 $ (3*k^2+1), k=0..10); # Robert Israel, Jan 03 2017
  • Mathematica
    Module[{nn=70,c},c=Range[0,Ceiling[Surd[nn,3]]]^3;Flatten[Array[ Nearest[ c,#]&,nn,0]]] (* Harvey P. Dale, May 27 2014 *)
  • Python
    from sympy import integer_nthroot
    def A201053(n):
        a = integer_nthroot(n,3)[0]
        return a**3 if 2*n < a**3+(a+1)**3 else (a+1)**3 # Chai Wah Wu, Mar 31 2021

Formula

G.f.: (1-x)^(-1)*Sum_{k>=0} (3*k^2+3*k+1)*x^((k+1)*(k^2+k/2+1)). - Robert Israel, Jan 03 2017
Sum_{n>=1} 1/a(n)^2 = Pi^4/30 + Pi^6/945. - Amiram Eldar, Aug 15 2022

A201217 Numbers such that (closest square) = (closest cube).

Original entry on oeis.org

0, 1, 2, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739
Offset: 1

Views

Author

Reinhard Zumkeller, Nov 28 2011

Keywords

Comments

A061023(a(n)) = 0; A053187(a(n)) = A201053(a(n));
A001014 is a subsequence (6th powers).

Programs

  • Haskell
    import Data.List (elemIndices)
    a201217 n = a201217_list !! (n-1)
    a201217_list = elemIndices 0 a061023_list
    -- Reinhard Zumkeller, Nov 28 2011

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.
Showing 1-4 of 4 results.