I'm trying to write a function that takes in two elements n
and m
and will try to give a count of the digits in n
that are multiples of m
.
For example, if n = 650899, m = 3
, the answer is 4
because the digits {6, 0, 9, 9}
are all evenly divisible by 3
, while the digits {5, 8}
are not:
Calculation Cumulative count
---------------- ----------------
6 / 3 = 2 1
5 / 3 = 1.666...
0 / 3 = 0 2
8 / 3 = 2.666...
9 / 3 = 3 3
9 / 3 = 3 4 <- Answer
I'm trying to do this without using strings at all (such as by checking individual characters within the string). Does anyone know how I can manipulate just the number by itself?