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.

A352631 Minimum number of zeros in a binary n-digit perfect square, or -1 if there are no such numbers.

This page as a plain text file.
%I A352631 #28 Mar 16 2025 12:43:26
%S A352631 0,-1,2,2,2,3,2,4,3,4,3,4,4,5,2,5,4,6,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7,
%T A352631 7,7,7,7,8,6,8,8,6,7,7,8,8,9,8,9,9,8,9,10,9,9,10,9,9,9,9,10,10,10,10,
%U A352631 11,10,11,11,11,9,9,11,11,11,12,11,12,11,12
%N A352631 Minimum number of zeros in a binary n-digit perfect square, or -1 if there are no such numbers.
%C A352631 Is there a formula that is easy to compute?
%e A352631 a(6) = 3, because there are two 6-bit squares 36 = 100100_2 and 49 110001_2 with 4 and 3 zeros, respectively.
%e A352631 a(2) = -1, because the first two perfect squares 1 = 1_2 and 4 = 100_2 have 1 and 3 bits, respectively.
%o A352631 (Python)
%o A352631 from gmpy2 import is_square, popcount
%o A352631 for n in range(1, 33):
%o A352631     m=n+1
%o A352631     for k in range(2**(n-1), 2**n):
%o A352631         if is_square(k):
%o A352631             m=min(m, n-popcount(k))
%o A352631     print(n, -1 if m>n else m)
%o A352631 (Python)
%o A352631 from math import isqrt
%o A352631 def A352631(n): return -1 if n == 2 else min(n-(k**2).bit_count() for k in range(1+isqrt(2**(n-1)-1),1+isqrt(2**n))) # _Chai Wah Wu_, Mar 28 2022
%Y A352631 Cf. A000290, A023416, A070939.
%Y A352631 Cf. A357658 (maximum 1's).
%K A352631 sign,base
%O A352631 1,3
%A A352631 _Martin Ehrenstein_, Mar 25 2022
%E A352631 a(43)-a(71) from _Pontus von Brömssen_, Mar 26 2022
%E A352631 a(72)-a(80) from _Chai Wah Wu_, Apr 01 2022