Determine the minimum value of a positive integer N that satisfy the following conditions:
- N is a multiple of 101.
- N starts with and ends in 98.
- sod(N) = 94
*** sod(N) denotes the sum of the digits of N.
For example, sod(3456) = 3+4+5+6 = 18
The 10 digit number 9,899,999,998 has a sod of 88, and this is the largest 10 digit number beginning and ending with '98'. This is not large enough, so the number needs to be at least 11 digits.
The 11 digit number 98,999,999,998 has a sod of 97. This is only 3 more than the desired sod of 94. So the bank of 9s will collectively be decremented 3 times. Also working mod 101 we have 98,999,999,998 = -9+89-99+99-99+98 = 79 mod 101
Now look at powers of 10 mod 101, those have four possible values: 1, 10, 100(same as -1), and 91(same as -10).
So then we desire 79 + some choices of {1, 10, 100, or 91} = 0 mod 101. But the smallest number of choices is five: 79 + 1 + 1 + 10 + 10 + 10 = 0 mod 101. This is more than the three times implied earlier, so no solution at 11 digits.
The 12 digit number 989,999,999,998 has a sod of 106. This is 12 more than the desired 94. So the bank of 9s will collectively be decremented 12 times. Also working mod 101 we have 989,999,999,998 = -98+99-99+99-99+98 = 0 mod 101.
Then we want 12 choices of {1, 10, 100, or 91} = 0 mod 101. This is easy to accomplish by pairing choices of 1 with 100 and choices of 10 with 91. Or equivalently decrement a pair of 9's that are split by one other 9; such as the 5th and 7th digit 9's in the number. Or possibly a pair of 9's with five intervening digits.
We want a minimum value, so lets take half of the 12 and apply them to the first 9 in the block of 9s, for an in-process value of 983,999,999,998
Again seeking a minimum we will choose the counterpart 9 to decrement is two digits later. Decrementing that 9 the other six times gives the answer of 983,939,999,998.