cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

Original entry on oeis.org

1, 0, 0, 0, 2, 1, 1, 10, 30, 20, 23, 0, 160, 419, 740, 0, 5116, 47677
Offset: 2

Views

Author

Chai Wah Wu, Mar 06 2024

Keywords

Comments

From Chai Wah Wu, Mar 10 2024: (Start)
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.
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.
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).
(End)

Examples

			For n=2 there is one penholodigital square, 1_2 = 1 = 1^2.
For n=6 there are two penholodigital squares, 15324_6 = 2500 = 50^2 and 53241_6 = 7225 = 85^2.
For n=7 there is one penholodigital square, 623514_7 = 106929 = 327^2.
For n=8 there is one penholodigital square, 6532471_8 = 1750329 = 1323^2.
For n=10 there are 30 penholodigital squares listed in A036744.
		

Crossrefs

Programs

  • Python
    from gmpy2 import mpz, digits, isqrt
    def A370950(n): # requires 2 <= n <= 62
        if n&1 and (~(m:=n-1>>1) & m-1).bit_length()&1:
            return 0
        t = ''.join(digits(d,n) for d in range(1,n))
        k = mpz(''.join(digits(d,n) for d in range(n-1,0,-1)),n)
        k2 = mpz(t,n)
        c = 0
        for i in range(isqrt(k2),isqrt(k)+1):
            if i%n:
                j = i**2
                s = ''.join(sorted(digits(j,n)))
                if s == t:
                    c += 1
        return c

Formula

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

Extensions

a(18) from Chai Wah Wu, Mar 07 2024
a(19) from Chai Wah Wu, Mar 15 2025