login
A258103
Number of pandigital squares (containing each digit exactly once) in base n.
7
0, 0, 1, 0, 1, 3, 4, 26, 87, 47, 87, 0, 547, 1303, 3402, 0, 24192, 187562
OFFSET
2,6
COMMENTS
For n = 18, the smallest and largest pandigital squares are 2200667320658951859841 and 39207739576969100808801. For n = 19, they are 104753558229986901966129 and 1972312183619434816475625. For n = 20, they are 5272187100814113874556176 and 104566626183621314286288961. - Chai Wah Wu, May 20 2015
When n is even, (n-1) is a factor of the pandigital squares. When n is odd, (n-1)/2 is a factor with the remaining factors being odd. Therefore, when n is odd and (n-1)/2 has an odd number of 2s as prime factors there are no pandigital squares in base n (e.g. 5, 13, 17 and 21). - Adam J.T. Partridge, May 21 2015
If n is odd and (n-1)/2 has an odd 2-adic valuation, then there are no squares in base n using all the digits from 1 to n-1 once, or all the digits from 0 to n-2 once or all the digits from 1 to n-2 once. This can be proved using the same argument as in the linked blogposts. - Chai Wah Wu, Feb 25 2024
LINKS
Chai Wah Wu, Pandigital and penholodigital numbers, arXiv:2403.20304 [math.GM], 2024. See p. 2.
EXAMPLE
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.
PROG
(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
(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))]
CROSSREFS
KEYWORD
base,nonn,more
AUTHOR
Adam J.T. Partridge, May 20 2015
EXTENSIONS
a(17)-a(19) from Giovanni Resta, May 20 2015
STATUS
approved