2015 AMC 10A Problem 18
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 ?
Show solution without answering
Key insight
In base 16, 1000 is 3E8. Every three-digit string of digits 0 to 9 starting with 0 to 3 is below it: 400 strings, minus zero.
Solution
First see how big is in base , then count the numbers written with only the digits to .
1. Write in base 16. The place values are , and . Since and is too big, the first digit is . What is left is . Fourteen is the digit , so
2. So every number from to has at most three base-16 digits, and a three-digit one starts with , or .
3. Count the digit strings. Think of every number as three digits, with leading zeros if needed (like ). We want strings that use only to :
- first digit: or ( choices), since or more is already past ;
- second digit: to ( choices);
- third digit: to ( choices).
That is strings.
4. Are they all at most 1000? The biggest one is
which is less than . So yes, all of them.
5. One string is , which is the number . It is not a positive integer, so take it away: .
6. The question asks for the sum of the digits of : .
The answer is .
Why this works
Counting numbers with only certain digits is a multiplication count, one factor per digit place. The upper limit is the tricky part: write the limit in the same base, and check whether the biggest allowed string is under it. Here it is (), so no extra cases are needed. Also watch the two small details at the end: remove zero, and answer the digit sum, not .
Concise solution
A shorter write-up, the way contest solutions are usually written. It may take a different route from the solution above.
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 .
Review in the AoPS books
- Introduction to Number Theory, Chapter 8: Base Numbers
- Introduction to Counting & Probability, Chapter 1: Counting Is Arithmetic
- Introduction to Number Theory, Chapter 9: Base Number Arithmetic
- Introduction to Counting & Probability, Chapter 2: Basic Counting Techniques
Similar problems
Problem © Mathematical Association of America (MAA), American Mathematics Competitions. Reproduced for non-commercial educational use. Solution and commentary are original to this site.