abcd = efgh * i a * 10^3 + b * 10^2 + c * 10^1 + d * 10^0 = (e * 10^3 + f * 10^2 + g * 10^1 + h * 10^0) * i => (e*i-a)*10^3 + (f*i-b)*10^2 + (g*i-c)*10^1 + (h*i-d)*10^0 = 0 for the above to have a chance to be zero: 1) ((h*i-d) * 10^0) % 10^1 = 0 (e.g. must end in 0) 2) The cumulative sum of the above at position J, (i.e. from right to left, J=0 for the term (h*i-d) * 10^0 ) must also end in zeros as follows: cum-sum at pos J=1 must end in 00 cum-sum at pos J=2 must end in 000 etc. 3) The cumulative sum of the above at position J, from right to left must also not be less than: cum-sum at pos J+1 >= 100 cum-sum at pos J+2 >= 1000 etc.