OFFSET
2,2
COMMENTS
a(n) >= ceiling(log_2(n)*(n-1)), whenever a(n)>0. This is because in order for an integer to have n digits in base n it must have at least a magnitude of n-1 in base n.
a(n) = 0 at all powers of 2 (except 2 itself). This is because powers of 2 in power-of-2 bases can only have 2 distinct digits. Is a(n) equal to 0 for any other values of n?
It seems that the base n representation of 2^(2*n^2) contains all n digits whenever n is not a power of 2. A proof of this would yield a negative answer to the above question. In the absence of a negative answer to this question, at least an algorithm would be desirable whose application to any concrete value of n solves the problem whether a(n)=0 for this n (for instance, if a(n)<n^2 for all n then a proof of this would yield such an algorithm). - Dimiter Skordev, Aug 18 2021
LINKS
Chai Wah Wu, Table of n, a(n) for n = 2..512 (n = 2..256 from Ely Golden).
EXAMPLE
a(3) = 5, since 2^5 is the smallest power of 2 which contains every digit in base 3: Namely, 2^5 is 1012 in base 3, whereas the previous powers are 1, 2, 11, 22, and 121, respectively, none of which contain all possible base-3 digits.
MATHEMATICA
TakeWhile[#, # > -1 &] &@ Table[If[And[IntegerQ@ #, # > 1] &@ Log2@ n, 0, SelectFirst[Range[2^11], Times @@ DigitCount[2^#, n] > 0 &]] /. k_ /; MissingQ@ k -> -1, {n, 2, 64}] (* Michael De Vlieger, Sep 05 2017 *)
PROG
(Python)
def floorLog(b, n):
x=-1
while(n>0):
x+=1
n//=b
return x
def distinctDigits(n, b):
li=[]
while(n>0):
li.append(n%b)
n//=b
li=list(set(li))
li.sort()
return li
def iroot(k, n):
u, s = n, n+1
while u < s:
s = u
t = (k-1) * s + n // (s**(k-1))
u = t // k
return s
def perfectPower(n):
if(n==1): return 0
x=1
for i in range(2, floorLog(2, n)+1):
if(iroot(i, n)**i==n): x=i
return x
def leastPandigital(b, n):
if(n<=1 or b<=1): return 0
if(n==2): return 2 if (b==(1<<b.bit_length())-1) else 1
if(iroot(perfectPower(n), n)==iroot(perfectPower(b), b)): return 0
a=(floorLog(b, n)*(n-1))
while(distinctDigits(b**a, n)!=list(range(n))): a+=1
return a
for i in range(2, 257):
print(str(i)+" "+str(leastPandigital(2, i)))
(Python)
from sympy.ntheory.digits import digits
def a(n):
b = bin(n)[2:]
if b.strip('0') == '1': return int(n == 2)
k = (len(b)-1)*(n-1)
while len(set(digits(2**k, n)[1:])) != n: k += 1
return k
print([a(n) for n in range(2, 65)]) # Michael S. Branicky, Oct 07 2021
(PARI) a(n) = {if (n==2, return (1)); if (ispower(n, , &k) && (k==2), return (0)); k = 1; while (#Set(digits(2^k, n)) != n, k++); k; } \\ Michel Marcus, Sep 06 2017
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Ely Golden, Sep 05 2017
STATUS
approved