Problem:
For any positive integer x, let S(x) be the sum of the digits of x, and let T(x) be ∣S(x+2)−S(x)∣. For example, T(199)=∣S(201)−S(199)∣=∣3−19∣=16. How many values T(x) do not exceed 1999?
Solution:
If the final digit of x is less than 8, then S(x+2)=2+S(x), so T(x)=2. When the last digit of x is 8, then x has the form A∣B∣8, where B is a block of k nines, k is nonnegative, and the final digit of the block A is not 9. Because x+2 has the form (A+1)∣Z, where Z is a block of k+1 zeros, it follows that T(x)=S(x)−S(x+2)= S(A)+9k+8−S(A+1)=S(A)+9k+8−S(A)−1=9k+7. When the last digit of x is 9, then x has the form A∣B, where B is a block of k nines, k is positive, and the final digit of A is not 9. Because x+2 has the form (A+1)∣Z∣1, where Z is a block of k−1 zeros, it follows that T(x)=S(x)−S(x+2)=S(A)+9k−S(A+1)−1=9k−2. Notice that the sequence 9k+7 for nonnegative k coincides with the sequence 9k−2 for positive k. Thus T can have the values 7,16,25,…,1996, and2.There are 91​(1996−(−2))+1=223​ values in all.
The problems on this page are the property of the MAA's American Mathematics Competitions