Hexadecimal (base-16) numbers are written using numeric digits through as well as the letters through to represent through . Among the first positive integers, there are whose hexadecimal representation contains only numeric digits. What is the sum of the digits of ?
- A)
- B)
- C)
- D)
- E)
Answer
E
Key insight
Since 1000 = 3E8 in hex, every all-numeric hex string up to 399 (decimal 921) is in range: 4*10*10 - 1 = 399 numbers, digit sum 21.
Solution
First locate in hexadecimal: , so . Every integer from to has at most three hex digits, with leading digit at most .
Now count hex strings (leading zeros allowed) using only digits through whose value is at most . The leading digit must be or , since would give at least . If and the other digits are at most , the largest such number is , so every one of these strings is in range.
That gives strings, one of which is , representing , which is not a positive integer. Hence , and its digit sum is .
The answer is .
Why this works
Counting numbers with restricted digits is a multiplication-principle count, but the upper limit must be handled carefully: convert the limit to the base in question, then check whether the largest "allowed" string falls below or above it. Here the check is clean (), so no boundary casework is needed. Also note the problem asks for the digit sum of , not itself.
The trap
Counting 400 by including 0 (which is not a positive integer), or not checking that 399 in hex is really below 1000 and 400 in hex is above it.
Common mistakes
- Counting by including (which is not a positive integer), or not checking that in hex is really below and in hex is above it.
- Answering or its decimal-digit sum of the wrong quantity (for example summing the digits of to get ).
Techniques
Bound the quantity above/below or estimate to pin it down · Set up the equation/formula and compute; no special trick needed