(PARI) See Greathouse link.
(Python)
from itertools import permutations
from gmpy2 import digits
def A239437(n): # requires 3 <= n <= 62
....m = n
....while True:
........s = ''.join([digits(i, m) for i in range(m)])
........for d in permutations(s, m):
............if d[0] != '0':
................c = mpz(''.join(d), m)
................for b in range(3, n):
....................if len(set(digits(c, b))) == b:
........................break
................else:
....................return int(c)
|