login
Number of penholodigital squares (containing each nonzero digit exactly once) in base n.
1

%I #35 Apr 04 2024 10:14:09

%S 1,0,0,0,2,1,1,10,30,20,23,0,160,419,740,0,5116

%N Number of penholodigital squares (containing each nonzero digit exactly once) in base n.

%C From _Chai Wah Wu_, Mar 10 2024: (Start)

%C Theorem: Let m^2 be a pandigital square (containing each digit exactly once) or a penholodigital square (containing each nonzero digit exactly once) in base n. If n-1 is an odd squarefree number (A056911), then m is divisible by n-1. If n-1 is an even squarefree number (A039956), then m-(n-1)/2 is divisible by n-1.

%C Proof: Since n^k == 1 (mod n-1), and the sum of digits of m^2 is n*(n-1)/2, this implies that m^2 == n*(n-1)/2 (mod n-1). If n-1 is odd and squarefree, then n is even and m^2 == 0 (mod n-1). Since n-1 = Product_i p_i for distinct odd primes p_i, and m^2 == 0 (mod p_i) if and only if m == 0 (mod p_i), this implies that m == 0 (mod n-1) by the Chinese Remainder Theorem.

%C Similarly, if n-1 is even and squarefree, then m^2 == n(n-1)/2 == (n-1)/2 (mod n-1) and (n-1)/2 = Product_i p_i for distinct odd primes p_i, i.e., m^2 == 0 (mod p_i) and m^2 == 1 (mod 2). This implies that m == 0 (mod p_i) and m == 1 (mod 2). Again by the Chinese Remainder Theorem, m == (n-1)/2 (mod n-1).

%C (End)

%H Chai Wah Wu, <a href="https://arxiv.org/abs/2403.20304">Pandigital and penholodigital numbers</a>, arXiv:2403.20304 [math.GM], 2024. See p. 2.

%F If n is odd and n-1 has an even 2-adic valuation, then a(n) = 0 (see A258103).

%e For n=2 there is one penholodigital square, 1_2 = 1 = 1^2.

%e For n=6 there are two penholodigital squares, 15324_6 = 2500 = 50^2 and 53241_6 = 7225 = 85^2.

%e For n=7 there is one penholodigital square, 623514_7 = 106929 = 195^2.

%e For n=8 there is one penholodigital square, 6532471_8 = 1750329 = 1323^2.

%e For n=10 there are 30 penholodigital squares listed in A036744.

%o (Python)

%o from gmpy2 import mpz, digits, isqrt

%o def A370950(n): # requires 2 <= n <= 62

%o if n&1 and (~(m:=n-1>>1) & m-1).bit_length()&1:

%o return 0

%o t = ''.join(digits(d,n) for d in range(1,n))

%o k = mpz(''.join(digits(d,n) for d in range(n-1,0,-1)),n)

%o k2 = mpz(t,n)

%o c = 0

%o for i in range(isqrt(k2),isqrt(k)+1):

%o if i%n:

%o j = i**2

%o s = ''.join(sorted(digits(j,n)))

%o if s == t:

%o c += 1

%o return c

%Y Cf. A039956, A056911, A036744, A071519, A258103.

%K nonn,base,more

%O 2,5

%A _Chai Wah Wu_, Mar 06 2024

%E a(18) from _Chai Wah Wu_, Mar 07 2024