Base K to Decimal
The string digits holds a number written in base k (2 to 10), with each character a digit from "0" to "9" smaller than k. Return its value as an ordinary integer.
Example 1
digits "1011"
k 2
returns 11
8 + 0 + 2 + 1 = 11.
Example 2
digits "202"
k 7
returns 100
2*49 + 2 = 100.
Constraints
1 <= len(digits) <= 102 <= k <= 10
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Math problems
- Collatz StepsBeginner
- Count DivisorsBeginner
- Decimal to Binary StringBeginner
- Digit Sum in Base KBeginner
- Digital RootBeginner
- Excel Sheet Column NumberBeginner
- Handshake CountBeginner
- Harshad NumberBeginner