1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

do_count_same_digits( a_{6}a_{5}a_{4}a_{3}a_{2}a_{1}a_{0}, b_{2}b_{1}b_{0} )
first: a_{6}a_{5}a_{4}a_{3}a_{2}a_{1}a_{0}
second: b_{2}b_{1}b_{0}
a_{0} == first % 10, and b_{0} = second % 10
a_{6}a_{5}a_{4}a_{3}a_{2}a_{1} == first / 10, and b_{2}b_{1} = second / 10
if( b_{0} == a_{0} )
count_same_digits = 1 + do_count_same_digits( a_{6}a_{5}a_{4}a_{3}a_{2}a_{1}, b_{2}b_{1} )
else
count_same_digits = 0 + do_count_same_digits( a_{6}a_{5}a_{4}a_{3}a_{2}a_{1}, b_{2}b_{1} )
ie. ( b_{0} == a_{0} ) + do_count_same_digits( a_{6}a_{5}a_{4}a_{3}a_{2}a_{1}, b_{2}b_{1} )
or ( b_{0} == a_{0} ) + do_count_same_digits( first/10, second/10 )
...............................................................
do_count_same_digits( a_{6}a_{5}a_{4}a_{3}a_{2}a_{1}, b_{2}b_{1} )
first: a_{6}a_{5}a_{4}a_{3}a_{2}a_{1}
second: b_{2}b1
a_{1} == first % 10, and b_{1} = second % 10
a_{6}a_{5}a_{4}a_{3}a_{2} == first / 10, and b_{2} = second / 10
if( b_{1} == a_{1} )
count_same_digits = 1 + do_count_same_digits( a_{6}a_{5}a_{4}a_{3}a_{2}, b_{2} )
else
count_same_digits = 0 + do_count_same_digits( a_{6}a_{5}a_{4}a_{3}a_{2}, b_{2} )
ie. ( b_{1} == a_{1} ) + do_count_same_digits( a_{6}a_{5}a_{4}a_{3}a_{2}, b_{2} )
and so on till one of the numbers reaches zero
.....................................................
Which gives us:
do_count_same_digits( a_{6}a_{5}a_{4}a_{3}a_{2}a_{1}a_{0}, b_{2}b_{1}b_{0} )
== (a_{0} == b_{0} ) + ( a_{1} == b_{1} ) + do_count_same_digits( a_{6}a_{5}a_{4}a_{3}a_{2}, b_{2} )
== (a_{0} == b_{0} ) + ( a_{1} == b_{1} ) + ( a_{2} == b_{2} ) + do_count_same_digits( a_{6}a_{5}a_{4}a_{3}, 0 )
== (a_{0} == b_{0} ) + ( a_{1} == b_{1} ) + ( a_{2} == b_{2} ) + 0
 