Why is using the mod feature wrong?
Can some one help me to find out why using the mod feature is wrong?We know the mod feature that (x%10 + y%10)%10 == (x+y)%10.Suppose the string is: abcdefAfter
Can some one help me to find out why using the mod feature is wrong?

We know the mod feature that (x%10 + y%10)%10 == (x+y)%10.



Suppose the string is: abcdef



After the 1st loop, we'll get: ```(a+b) %10, (b+c) %10, (c+d)%10, (d+e)%10, (e+f)%10```.

Since ```(x%10 + y%10)%10 == (x+y)%10```, we should have ```((a+b) %10, (b+c) %10)%10 -> (a+2b+c)%10```.

After the 2nd loop, we'll get: ```(a+2b+c)%10, (b+2c+d)%10, (c+2d+e)%10, (d+2e+f)%10```.

After the 3rd loop, we'll get: ```(a+3b+3c+d)%10, (b+3c+3d+e)%10, (c+3d+3e+f)%10```.

After the 4th loop, we'll get: ```(a+4b+4c+4d+e)%10, (b+4c+4d+4e+f)%10```.



Based on this, for case "321881" which a=3, b=2, c=1, d=8, e=8, f=1,

The final 2 digits should be ```(a+4b+4c+4d+e)%10``` and ```(b+4c+4d+4e+f)%10``` which is ```(3+4*(2+1+8)+8)%10, (2+4*(1+8+8)+1)%10 -> 5,1```.

But the actual result is the following:

321881

1st loop: 5, 3, 9, 6, 9

2nd loop: 8, 2, 5, 5

3rd loop: 0, 7, 0

4th loop: 7, 7

These two results -- (5,1) and (7,7) -- are not the same, why? I cannot find out where is wrong...


['C++']