login
Smallest integer containing all digits in all bases from 2 to n.
7

%I #42 Jun 29 2022 01:50:21

%S 2,11,75,978,8350,160773,2217404,45623244,1093265784,37206483195,

%T 1587937206284,109746121381518,2697545063614180,64810523515743579,

%U 21538286780426129155

%N Smallest integer containing all digits in all bases from 2 to n.

%C a(12) is the first term whose expansion in base n does not begin with a 1. - Tom Womack

%C By definition, for n >= 3, a(n) > A000169(n), with equality when n=2 only. - _Michel Marcus_, Nov 10 2013

%C a(16) is the first term which is bigger than n^n, i.e., whose expansion in base n=16 is not a permutation of 16 different digits. - _Ignat Soroko_, Aug 14 2017

%H Project Euler, <a href="http://projecteuler.net/problem=571">Problem 571: Super Pandigital Numbers</a>

%e 75 is the smallest integer containing 0 and 1 in base 2 (1001011), 0, 1 and 2 in base 3 (2210) and 0, 1, 2 and 3 in base 4 (1023), hence a(4) = 75.

%e a(12) = 1587937206284 is 217904B5A638 in base 12; 562493178A90 in base 11.

%o (PARI) isok(i, n) = {for (b = 2, n, if (#Set(digits(i, b)) != b, return (0));); return (1);}

%o a(n) = {i = n^(n-1); while (! isok(i, n), i++); i;} \\ _Michel Marcus_, Nov 10 2013

%o (Python)

%o from itertools import count, product

%o from sympy.utilities.iterables import multiset_permutations

%o from gmpy2 import digits, mpz

%o def A055085(n): # assumes n <= 62

%o dlist = tuple(digits(d,n) for d in range(n))

%o for l in count(n-1):

%o for t in product(dlist,repeat=l-n+1):

%o for d in range(1,n):

%o for u in multiset_permutations(sorted(t+dlist[:d]+dlist[d+1:])):

%o m = mpz(''.join((dlist[d],)+tuple(u)),n)

%o for b in range(n-1,1,-1):

%o if len(set(digits(m,b))) < b:

%o break

%o else:

%o return int(m) # _Chai Wah Wu_, Mar 14 2022

%Y A051640 uses a weaker definition.

%K nonn,base

%O 2,1

%A Ulrich Schimke (ulrschimke(AT)aol.com)

%E a(11) from _David Wasserman_, Mar 25 2002

%E a(12) from Tom Womack (tom(AT)womack.net), Jun 19 2007

%E a(13)-a(15) from _Ignat Soroko_, Jan 05 2017

%E a(16) from _Ignat Soroko_, Aug 14 2017