I am trying to iterate through some number as 02100021, this is a routing number which needs to get validated if it is a proper routing number. Therefore I am using the ABA routing number validation check as 3*(d1+d4+d7) + 7*(d2+d5+d8) + (d3+d6+d9) where mod 10 = 0
Since I have the number in integer type, my first question is how can I iterate through such number with 0’s in it, or if there is some easier way of iterating through mode and multiplying it with such number.
Thanks
If I understand correctly,
7 * (d2, d5, d8)should be7 * (d2 + d5 + d8).Zeros modulo 10 do not count.
Corrected for d[i] = digit * 10 ^ (9 – i)
Modulo arithmetic can be done at the end.
To prevent overflow (to negative numbers) one might do it earlier, above even 7 * b does not overflow.