Project 96: Base K to Decimal
Converting to Decimal from Other Bases
Similar logic can be used to convert to and from other bases. Examples for other bases are shown below:
Example 1: Convert 34 base 5 to decimal.
3*5^1 + 4*5^0 = 15 + 4 = 19
Example 2: Convert 212 base 8 to decimal.
2*8^2 + 1*8^1 + 2*8^0 = 128 + 8 + 2 = 138
Example 3: Convert 88 base 9 to decimal.
8*9^1 + 8*9^0 = 72 + 8 = 80
Project 96: Variables 'baseKNumber' and 'base' have been initialized.
baseKNumber is an array of digits.
For example 1: baseKNumber is [3, 4].
base is the base for the number.
For example 1: base is 5.
Task: Appropriately initialize the value for the variable 'decimal'.
For example 1: decimal should be 19.
**If your code works for 5 test cases, you can enter your e-mail address
Universal Computational Math Methods:
pow(5,2) returns 25.0
abs(-3.0) returns 3
sqrt(49.0) returns 7.0