Power by repeating
Inputs
base is a whole number from 1 to 6. exp is a whole number from 0 to 8.
Your tasks
- Create a number
resultthat starts at 1. - Use a loop that runs
exptimes. Each round multipliesresultbybase. - Complete
powerso it returnsresult. Return it, do not print it.
Example
With base = 2 and exp = 5, power returns 32.
Rules
- Do not use a power operator or a power function.
- Any
baseto the power 0 is 1.
Test data
TEST DATA 1: base is 2, exp is 5
TEST DATA 2: base is 6, exp is 0
Practice focus
Loops that count, add up and multiply. Every algorithm starts here: a counter, a total and a stopping point.