A291926 a(n) is the smallest integer k>=0 such that 2^k contains every digit in base n, or 0 if no such integer exists.
1, 5, 0, 18, 25, 20, 0, 61, 68, 64, 72, 103, 110, 134, 0, 138, 141, 140, 141, 172, 191, 228, 225, 244, 306, 281, 272, 339, 384, 412, 0, 390, 421, 372, 472, 395, 441, 486, 495, 473, 566, 576, 629, 735, 626, 661, 706, 707, 741, 825, 782, 751, 811, 924, 930, 908, 927, 975, 1049, 934, 1018, 1070, 0
Offset: 2
Examples
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.
Links
- Chai Wah Wu, Table of n, a(n) for n = 2..512 (n = 2..256 from Ely Golden).
Crossrefs
Cf. A090493.
Programs
-
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 *)
-
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
-
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<
-
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
Comments