An excellent number n has an even number of digits and, if you split the number into the front half a and the back half b, then b^2 − a^2 = n.

For example, 3468 = 68^2 − 34^2.

The only two-digit excellent number is 48 and the only four-digit

excellent number is 3468.

There are eight six-digit excellent numbers.

List them.

Bonus: List all 10-digit excellent numbers.

Source: Project Euler.

My earlier equation (2b-1)^2 = 4a*(a+10^k)+1 can still benefit from more algebraic manipulation, specifically to make it into a difference of squares: (2a+10^k)^2 - (2b-1)^2 = 10^(2k) - 1. Then finding excellent numbers is reduced to testing factorizations of 10^(2k) - 1.

Let f*g be a factorization of 10^(2k) - 1 with f>g. Then **a = (f+g-2*10^k)/4 and b = (f-g+2)/4**.

Testing this with k=1. 99 has 3 factorizations {99*1, 33*3, 11*9} only one of which results in a valid excellent number: 9=33*3 implies a = (33+3-20)/4 = 4 and b = (33-3+2)/4 = 8, which makes the two digit excellent number 48.

So looking for 14 digit excellent numbers starts with factoring 10^14-1 (prime factorization 3*3*11*239*4649*909091). Only 2 of the 24 f*g factorizations resulted in valid numbers:

f*g = 36666663*2727273 yielded 4848484 8484848

f*g = 30000003*3333333 yielded 3333334 6666668