Originally Posted by

**alexmahone** Case 8: If the last digit of n is 7, the last digit of n + 3 is 0. If i digits preceding the last digit are 9, they will all become 0. The digit before the i digits (equal to 9) will increase by 1, and so the sum of digits of n + 3 will be the (sum of digits of n) - 9i 7 + 1 = (sum of digits of n) -9i - 6, which is also divisible by 3.

Case 9: If the last digit of n is 8, the last digit of n + 3 is 1. If i digits preceding the last digit are 9, they will all become 0 and not change the sum_of_digits % 3. The digit before the i digits (equal to 9) will increase by 1, and so the sum of digits of n + 3 will be the (sum of digits of n) - 9i - 7 + 1 = (sum of digits of n) 9i - 6, which is also divisible by 3.

Case 10: If the last digit of n is 9, the last digit of n + 3 is 2. If i digits preceding the last digit are 9, they will all become 0 and not change the sum_of_digits % 3. The digit before the i digits (equal to 9) will increase by 1, and so the sum of digits of n + 3 will be the (sum of digits of n) - 9i - 7 + 1 = (sum of digits of n) - 9i - 6, which is also divisible by 3.

Is this what you had in mind?