A258103 Number of pandigital squares (containing each digit exactly once) in base n.
0, 0, 1, 0, 1, 3, 4, 26, 87, 47, 87, 0, 547, 1303, 3402, 0, 24192, 187562
Offset: 2
Examples
For n=4 there is one pandigital square, 3201_4 = 225 = 15^2. For n=6 there is one pandigital square, 452013_6 = 38025 = 195^2. For n=10 there are 87 pandigital squares (A036745). There are no pandigital squares in bases 2, 3, 5 or 13. Hexadecimal has 3402 pandigital squares, the largest is FED5B39A42706C81.
Links
- A. J. T. Partridge, Why there are no pandigital squares in base 13
- Chai Wah Wu, Square pandigital numbers
- Chai Wah Wu, Pandigital and penholodigital numbers, arXiv:2403.20304 [math.GM], 2024. See p. 2.
Programs
-
PARI
a(n) = if(n%2==1 && valuation(n-1,2)%2==0, 0, my(lim=sqrtint(n^n - (n^n-n)/(n-1)^2), count=0); for(m=sqrtint((n^n-n)/(n-1)^2 + n^(n-2)*(n-1) - 1), lim, if(#Set(digits(m^2,n))==n, count++)); count) \\ Jianing Song, Feb 23 2024. Note that the searching range for m is [sqrt(A049363(n)), sqrt(A062813(n))]
-
Python
from gmpy2 import isqrt, mpz, digits def A258103(n): # requires 2 <= n <= 62 c, sm, sq = 0, mpz(''.join([digits(i, n) for i in range(n-1, -1, -1)]), n), mpz(''.join(['1', '0']+[digits(i, n) for i in range(2, n)]), n) m = isqrt(sq) sq = m*m m = 2*m+1 while sq <= sm: if len(set(digits(sq, n))) == n: c += 1 sq += m m += 2 return c # Chai Wah Wu, May 20 2015
Extensions
a(17)-a(19) from Giovanni Resta, May 20 2015
Comments