login
A342546
a(n)^2 is the least square with exactly n 1's in base n.
2
3, 7, 73, 141, 1417, 17130, 11677, 187955, 10252371, 20440221, 1550384575, 10645648530, 80224807014, 829050923579, 17071371319785, 599574561430568
OFFSET
2,1
EXAMPLE
n a(n) a(n)^2 in base n
2 3 9 1001
3 7 49 1211
4 73 5329 1103101
5 141 19881 1114011
6 1417 2007889 111011441
7 17130 293436900 10162113111
8 11677 136352329 1010111111
9 187955 35327082025 111160121111
10 10252371 105111111121641 105111111121641
PROG
(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)))
(Python)
from sympy import integer_nthroot
from numba import njit
@njit # works with 64 bits through a(12)
def digits1(n, b):
count1 = 0
while n >= b:
n, r = divmod(n, b)
count1 += (r==1)
return count1 + (n==1)
def a(n):
an = integer_nthroot(n**(n-1), 2)[0] + 1
while digits1(an*an, n) != n: an += 1
return an
print([a(n) for n in range(2, 10)]) # Michael S. Branicky, Apr 07 2021
CROSSREFS
KEYWORD
nonn,base,more
AUTHOR
Hugo Pfoertner, Apr 07 2021
EXTENSIONS
a(14) from Chai Wah Wu, Apr 14 2021
a(15)-a(16) from Giovanni Resta, Apr 17 2021
a(17) from Martin Ehrenstein, May 29 2021
STATUS
approved