Problem 44637. Still more miles to go before I sleep
It's time for more odometer fun. Last problem, my car's odometer hit 56789. It's coming up on 111111 now, which (barring a major miracle) will be the last binary number to ever show up on the odometer. You will be given two numbers - an odometer reading, and a number base. Calculate the number of miles your car will need to travel in order to show the next number that is valid in that base. If your odometer reading is already a valid number in that base, return 0.
For example, your input is an odometer reading of 12341 with a number base of 4. The next odometer reading that would be valid in base 4 is 13000, so the correct answer would be 13000-12341, or 659.
You can assume that the odometer reading is in base 10, the input is numerical and not a string, all numbers will be positive integers, and that your car will last that long without getting read-ended at a stop-light. Happy driving!
Solution Stats
Problem Comments
Solution Comments
Show commentsGroup

Number Manipulation IV
- 15 Problems
- 30 Finishers
- Pattern Sum
- Smallest n, for n! to have m trailing zero digits
- Still more miles to go before I sleep
- Convert from Base 10 to base 5
- Numbers on 7-segment
- Expand 10^n to Powers of 4
- Muphry's Law of MATLAB
- Lunar Arithmetic (Addition)
- Lunar Arithmetic (Multiplication)
- Permutation Via Multiplication
- The last non-zero digit of a factorial
- The number of trailing zero digit of a factorial
- Whole Number Concatenator
- Whole Number Un-Concatenator
- Smallest n, for n! to have m trailing zero digits
- Better Index Number
Problem Recent Solvers47
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!