But if you remove each of the five and four digit elements that are not already divisible by nine, the division operations come to 40,320. |
By definition of the problem, the larger five-digit operand must always be divisible by 9 to be included.
Using nines-complement principles, it can be proved that the divisor must also be divisible by 9, since the sum of set {1,2,3,. . . ,9} is 45, divisible by 9. Any multiple of 9 subtracted from 45 will leave a remainder that is also divisible by 9.
Actually the sum of set {a,b,c,d} must equal (45 - sum of set {e,f,g,h,i}), and because sum of set {1,2,3,4} can never be 9, one sum must be at least 18, the other sum not more than 27.
So there is no reason to divide any pair of numbers whose digit-sum isn't 18 and 27, or whose divisor is not mod 9.
What intrigues me is the ( is_mod && may_be. . .) eliminating so many division operations!