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

A362068 a(n) is the smallest positive integer k such that n can be expressed as the arithmetic mean of k squares.

Original entry on oeis.org

1, 2, 3, 1, 2, 3, 3, 2, 1, 2, 3, 3, 2, 3, 3, 1, 2, 2, 3, 2, 4, 3, 3, 3, 1, 2, 3, 3, 2, 3, 3, 2, 3, 2, 3, 1, 2, 3, 3, 2, 2, 3, 3, 3, 2, 3, 3, 3, 1, 2, 3, 2, 2, 3, 3, 3, 3, 2, 3, 3, 2, 3, 3, 1, 2, 3, 3, 2, 4, 3, 3, 2, 2, 2, 3, 3, 4, 3, 3, 2, 1, 2, 3, 4, 2, 3, 3, 3, 2, 2, 3, 3, 4, 3, 3, 3, 2, 2, 3, 1
Offset: 1

Views

Author

Yifan Xie, Apr 07 2023

Keywords

Comments

a(n) is the smallest number k such that n*k can be expressed as the sum of k squares.

Examples

			For n = 2, if k = 1, 2*1 = 2 is not a square; if k = 2, 2*2 = 4 = 2^2 + 0^2, so a(2) = 2.
		

Crossrefs

Cf. A360530 (nonzero), A004215.

Programs

  • PARI
    findsquare(k, m) = if(k == 1, issquare(m), for(j=0, m, if(j*j > m, return(0), if(findsquare(k-1, m-j*j), return(1)))));
    a(n) = {for(t = 1, 3, if(findsquare(t, n*t), return(t))); return(4)};
    
  • Python
    from sympy.ntheory.primetest import is_square
    from sympy import factorint
    def A362068(n):
        if is_square(n):
            return 1
        if all(map(lambda x:x[0]&3<3 or x[1]&1^1, factorint(k:=n>>(m:=(~n&n-1).bit_length())).items())):
            return 2
        if m&1 or 3*k&7<7:
            return 3
        return 4 # Chai Wah Wu, Apr 27 2023

Formula

a(n) <= 4. (Lagrange)

A362110 a(n) is the smallest integer k such that n can be expressed as the arithmetic mean of k distinct nonzero squares, or 0 if no such k exists.

Original entry on oeis.org

1, 0, 0, 1, 2, 0, 3, 0, 1, 2, 5, 0, 2, 3, 3, 1, 2, 3, 5, 2, 4, 3, 3, 5, 1, 2, 3, 3, 2, 3, 3, 5, 5, 2, 3, 1, 2, 3, 3, 2, 2, 3, 3, 5, 2, 3, 3, 5, 1, 2, 3, 2, 2, 3, 3, 3, 3, 2, 4, 3, 2, 3, 3, 1, 2, 3, 3, 2, 4, 3, 3, 3, 2, 2, 3, 5, 4, 3, 3, 2, 1, 2, 3, 4, 2, 3, 3, 3, 2, 2, 3, 3, 4, 3, 3, 5, 2, 3, 3
Offset: 1

Views

Author

Yifan Xie, Apr 16 2023

Keywords

Examples

			For n = 2, if k = 1, 2*1 = 2 is not a square; but, from the upper bound formula, (k + 1) * (2*k + 1) <= 12, so k <= 1. So, a satisfactory k does not exist; hence a(2) = 0.
		

Crossrefs

Cf. A360530 (allows repeated squares).

Formula

Upper bound: (a(n) + 1) * (2*a(n) + 1) <= 6*n. Proof: Because (Sum_{m=1..k} (i_m)^2)/k = n, n*k = Sum_{m=1..k} (i_m)^2. Since each i_m is distinct, n*k >= Sum_{m=1..k} m^2 = k * (k + 1) * (2*k + 1)/6, hence (k + 1) * (2*k + 1) <= 6*n.
a(A132777(n)) = 2. - Thomas Scheuerle, Apr 16 2023

Extensions

Name qualified and other edits by Peter Munn, Apr 21 2023
Showing 1-2 of 2 results.