This problem has too many cases for a trial and error method (more than 60 thousand) so mathematics is needed. It is possible to reduce the number of cases to 17 by using the sum of the six digit numbers to prove that the number N is a multiple of 5291. You can find the first digit, and hence an upper limit for the size of N, by using the fact that 6N has only six digits.