login
Largest number whose base-n representation does not contain any digit more than once and which is not divisible by any of its base-n digits, or 0 if no such number exists.
1

%I #29 Mar 08 2020 11:41:09

%S 0,0,0,35,577,5909,16331,2053379,42374099,987654203,2334368201,

%T 736867783013,23136292864661,789018236128979,1936265501684027,

%U 1147797409030816259,48471109094902544503,2178347851919531380901,5463472083532379956913,5228356786703601108032803

%N Largest number whose base-n representation does not contain any digit more than once and which is not divisible by any of its base-n digits, or 0 if no such number exists.

%D "Enigma 1343: Digital Dividend", New Scientist, Jun 04 2005, 28.

%H Enigmatic Code, <a href="https://enigmaticcode.wordpress.com/2014/03/01/enigma-1343-digital-dividend/">Enigma 1343: Digital Dividend</a>, from New Scientist, Jun 04 2005, 28.

%e There are 49 numbers whose base-4 representation does not contain repeated digits. Of these, the largest which is not divisible by any of its digits is a(4) = 203_4 = 35_10.

%e Any base-3 number containing only 0's and 2's with at least one 2 is divisible by 2, while any number with a 1 is divisible by 1, so no positive integer meets the criteria in base 3. Thus a(3) = 0.

%o (Sage)

%o def A114342(n):

%o dd = [0] + [2..n-1]

%o for width in [1..n-1][::-1]:

%o found = []

%o for dc in Combinations(dd, width):

%o m = sum(dc) % (n-1)

%o if gcd(m,n-1) in dc: continue # rule of nines

%o for p in Permutations(dc[::-1]):

%o s = sum((d)*n**i for i,d in enumerate(p[::-1]))

%o if not any(d != 0 and s % d == 0 for d in p): found.append(s)

%o if found and width == len(dd): return s

%o if found and s < max(found): break

%o if found: return max(found)

%o return 0 # _D. S. McNeil_, Oct 01 2011

%Y Cf. A113028.

%K nonn,base

%O 1,4

%A Francis Carr (fcarr(AT)alum.mit.edu), Feb 08 2006

%E a(12)-a(20) from _Nathaniel Johnston_, Sep 30 2011