Learn / Library / Brainteasers
Digit sum and alternating sum
How many integers from to have digit sum exactly and are divisible by ?
Checking an answer needs JavaScript. The hint and the solution open without it.
Hint
Write the number with leading zeros as digits, and split the digits into those in odd and even positions.
Solution
- Let be the sum of the digits in positions , , and the sum in positions , , ; then , and the number is divisible by exactly when is a multiple of .
- Because is odd, is odd, and since , it must be or , giving or .
- The number of triples of digits from to with sum is , and the triples with sum correspond to them by replacing each digit by , so there are also .
- Each of the cases gives numbers, so the total is .
Answer: