|
I don't think it would make a large difference in runtime, but the bounds aren't quite right. The largest possible value isn't 999,999,999, because that's not a legal value. The largest value is 987,654,321 Dividing that by 9, you get 109,739,369, but that's not a legal value either, you'd want to start with 109,738,365 for the gcd as it's a valid possible row. I don't know that all gcds would need to be a valid row, but any gcd larger than 98,765,432 would need to be used at multiples from 1-9; with that gcd or smaller, multiple 10 becomes viable and the gcd doesn't need to be valid with multiple of 1. |
The GCD search should start at 098,765,432 and then go down from there.