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 commentsProblem Recent Solvers46
Suggested Problems
-
Find state names that end with the letter A
1182 Solvers
-
1202 Solvers
-
368 Solvers
-
320 Solvers
-
Find the next Fibonacci number
670 Solvers
More from this Author80
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!