The main focus here was optimizing the pandigital testing. The rest is just looping over every possible number.  
We can optimize the outer loop a little bit if we look at the possible multiplicands.
There are only 2 possibilities if we need 9 digits in our calculation:

- 1-digit number * 4-digit number = 4-digit number
- 2-digit number * 3-digit number = 4-digit number