a. Suppose that n is a self-squared ℓ-code. Then the last ℓ digits of n2−n=n(n−1) are all zeros. This means that n(n−1) is divisible by 10ℓ. Vice versa, n is self-squared if n2−n is divisible by 10ℓ and thus ends in ℓ zeros.
b. The number n(n−1) is divisible by 10 and so, in particular, it is divisible by 5. This means that one of the numbers n and n−1 must be divisible by 5. In other words, the last digit of either n or n−1 must be a 0 or 5. So the only possible final digits for n are 0, 1, 5 and 6.
If the last digit of n is 0, then n−1 is not divisible by 2 or 5. Since n(n−1) is divisible by 10ℓ=2ℓ⋅5ℓ and there can be no factors 2 or 5 in n−1, n must be divisible by 10ℓ. But that means that the last ℓ digits of n, which are all the digits of n, must all be zeros. Then we get n=0, which is smaller than 2.
If the last digit of n is a 1, then n is not divisible by 2 or 5. Since n(n−1) is divisible by 10ℓ=2ℓ⋅5ℓ and there can be no factors 2 or 5 in n, n−1 must be divisible by 10ℓ. But that means that the last ℓ digits of n−1, which are all the digits of n−1, must all be zeros. Then we get n=1, which is smaller than 2.
So all self-quadratic codes n≥2 end in a 5 or 6.
c. Suppose that m=c⋅10ℓ+n is an (ℓ+1)-code obtained by putting c in front of n. Because of (a), m is self-squared if and only if
m(m−1)=(c⋅10ℓ+n)(c⋅10ℓ+n−1)=c2⋅102ℓ+c⋅10ℓ(2n−1)+n(n−1)
is divisible by 10ℓ+1. As ℓ≥1, the term c2⋅102ℓ is also divisible by 10ℓ+1. The number n(n−1) is divisible by 10ℓ, because of part (a), and can therefore be written as d⋅10ℓ. It then follows that
c⋅10ℓ(2n−1)+d⋅10ℓ=10ℓ⋅(c(2n−1)+d)
must be divisible by 10ℓ+1, or in other words that c(2n−1)+d must be divisible by 10.
Because of part (b), n must end in a 5 or 6. If n ends in a 5, then 2n−1 is a multiple of ten minus one, i.e. it is of the shape 10k−1, and we see that c(10k−1)+d must be divisible by 10 and so −c+d must be divisible by 10. On the other hand, if n ends in a 6, then 2n−1 is a multiple of ten plus one, say 10k+1, and we see that c(10k+1)+d must be divisible by 10 and so c+d must be divisible by 10.
In both cases, there is a unique possibility for c from the numbers 0, 1, 2, ..., 9 for which −c+d (or c+d) is divisible by 10, since, of the ten consecutive numbers −0+d,−1+d,...,−9+d (or 0+d,1+d,...,9+d), exactly one is divisible by 10. Therefore, there is a unique digit c that we can put before the ℓ-code n such that m is a self-squared (ℓ+1)-code.
d. Suppose that n≥2 is a self-squared ℓ-code. Then we will show that k=10ℓ+1−n is also a self-squared ℓ-code. Because n≥2, we have k≤10ℓ−1 and k can thus really be written using ℓ digits. From part (a) it follows that k is self-squared if and only if
k(k−1)=(10ℓ+1−n)(10ℓ−n)=102ℓ+10ℓ(1−2n)+(n−1)n
is divisible by 10ℓ. The first two terms are always divisible by 10ℓ and (n−1)n is divisible by 10ℓ because n is self-squared. So it follows that k is self-squared.
Since n≤10ℓ−1, we have k≥2. Furthermore, 10ℓ+1 is odd, and so one out of n and k is even and the other number is odd. In particular, n and k are thus not equal to each other. Since there are exactly two self-squared ℓ-codes ≥2, the other self-squared ℓ-code m must be equal to k. It then holds that m+n=k+n=10ℓ+1.