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.

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

This page as a plain text file.
%I A362068 #59 Aug 10 2023 09:02:38
%S A362068 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,
%T A362068 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,
%U A362068 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
%N A362068 a(n) is the smallest positive integer k such that n can be expressed as the arithmetic mean of k squares.
%C A362068 a(n) is the smallest number k such that n*k can be expressed as the sum of k squares.
%H A362068 Peter Munn, <a href="/A362068/b362068.txt">Table of n, a(n) for n = 1..10000</a>
%F A362068 a(n) <= 4. (Lagrange)
%e A362068 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.
%o A362068 (PARI)
%o A362068 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)))));
%o A362068 a(n) = {for(t = 1, 3, if(findsquare(t, n*t), return(t))); return(4)};
%o A362068 (Python)
%o A362068 from sympy.ntheory.primetest import is_square
%o A362068 from sympy import factorint
%o A362068 def A362068(n):
%o A362068     if is_square(n):
%o A362068         return 1
%o A362068     if all(map(lambda x:x[0]&3<3 or x[1]&1^1, factorint(k:=n>>(m:=(~n&n-1).bit_length())).items())):
%o A362068         return 2
%o A362068     if m&1 or 3*k&7<7:
%o A362068         return 3
%o A362068     return 4 # _Chai Wah Wu_, Apr 27 2023
%Y A362068 Cf. A360530 (nonzero), A004215.
%K A362068 nonn,easy
%O A362068 1,2
%A A362068 _Yifan Xie_, Apr 07 2023