A340501 Smallest square which when written in base b contains each digit exactly once, or -1 if no such square exists.
-1, -1, 225, -1, 38025, 314721, 3111696, 61058596, 1026753849, 31529329225, 892067027049, -1, 803752551280900, 29501156485626049, 1163446635475467225, -1, 2200667320658951859841, 104753558229986901966129, 5272187100814113874556176, -1, 15588378150732414428650569369
Offset: 2
Examples
base a(base) digits 4 225 [3, 2, 0, 1] 6 38025 [4, 5, 2, 0, 1, 3] 7 314721 [2, 4, 5, 0, 3, 6, 1] 8 3111696 [1, 3, 6, 7, 5, 4, 2, 0] 9 61058596 [1, 3, 6, 8, 0, 2, 5, 7, 4] 10 1026753849 [1, 0, 2, 6, 7, 5, 3, 8, 4, 9] 11 31529329225 [1, 2, 4, 0, 10, 5, 3, 6, 7, 8, 9] 12 892067027049 [1, 2, 4, 10, 7, 11, 5, 3, 8, 6, 0, 9] 14 803752551280900 [1, 0, 2, 6, 9, 11, 8, 12, 5, 7, 13, 3, 10, 4]
Links
- Chai Wah Wu, Table of n, a(n) for n = 2..29
Programs
-
Python
from sympy import integer_nthroot def digits(n, b): out = [] while n >= b: n, r = divmod(n, b); out.append(r) return [n] + out[::-1] def a(n): b, b2b = n, n**n r, a = integer_nthroot(b**(b-1), 2); s = r**2 while s < b**(b-1): s += 2*r + 1; r += 1 while s < b2b: if len(set(digits(s, b))) == n: return s s += 2*r + 1; r += 1 return -1 print([a(n) for n in range(2, 13)]) # Michael S. Branicky, Jan 13 2021
Extensions
a(10)-a(22) from Hugo Pfoertner and Alois P. Heinz, Jan 13 2021
Comments