Comments

If any number divides the given number for some n, then it automatically does for all n greater than that one. For example, since for n = 3, d = 3, 333333 is divisible by 7, all other numbers with d=3 and n>=3 will also be divisible by 7. You can see that by expressing the higher n numbers as sums of multiples of the previous ones by powers of 10. So, if you check for each digit you see that for n=3, 7 is always a factor. So for all possibilities with n>=3, 7 is a factor. Now for n<=2, the only possible case in which it is divisible by 7 is if the digit itself is 7.