Loading...
Loading...
Loading...
A savings scheme doubles, triples or multiplies your coins by a every month. Read a base a and a power b, and print a raised to the power b, using a loop and without Math.pow.
Any number to the power 0 is 1, and that includes 0 to the power 0 here.
long.Example 1
Input
2 10
Output
1024
2 multiplied by itself 10 times is 1024.
Example 2
Input
-3 3
Output
-27
An odd power of a negative number is negative.
Try the problem first. Open one hint at a time.
Start the answer at 1.
Multiply it by a, b times. Keep it in a long.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor