Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #28 May 30 2021 12:59:47
%S 3,7,73,141,1417,17130,11677,187955,10252371,20440221,1550384575,
%T 10645648530,80224807014,829050923579,17071371319785,599574561430568
%N a(n)^2 is the least square with exactly n 1's in base n.
%e n a(n) a(n)^2 in base n
%e 2 3 9 1001
%e 3 7 49 1211
%e 4 73 5329 1103101
%e 5 141 19881 1114011
%e 6 1417 2007889 111011441
%e 7 17130 293436900 10162113111
%e 8 11677 136352329 1010111111
%e 9 187955 35327082025 111160121111
%e 10 10252371 105111111121641 105111111121641
%o (PARI) for(b=2,10,for(k=1,oo,my(s=k^2,d=digits(s,b));if(sum(k=1,#d,d[k]==1)==b,print1(k,", ");break)))
%o (Python)
%o from sympy import integer_nthroot
%o from numba import njit
%o @njit # works with 64 bits through a(12)
%o def digits1(n, b):
%o count1 = 0
%o while n >= b:
%o n, r = divmod(n, b)
%o count1 += (r==1)
%o return count1 + (n==1)
%o def a(n):
%o an = integer_nthroot(n**(n-1), 2)[0] + 1
%o while digits1(an*an, n) != n: an += 1
%o return an
%o print([a(n) for n in range(2, 10)]) # _Michael S. Branicky_, Apr 07 2021
%Y Cf. A000290, A342260, A342545.
%K nonn,base,more
%O 2,1
%A _Hugo Pfoertner_, Apr 07 2021
%E a(14) from _Chai Wah Wu_, Apr 14 2021
%E a(15)-a(16) from _Giovanni Resta_, Apr 17 2021
%E a(17) from _Martin Ehrenstein_, May 29 2021