Exponents with while
Exercise Type: Paraphrasing
Instructions
Here is a bit of code that you can use to calculate exponents, with a
being the base and b
the exponent:
a^b
Part 1
Given that b
is an integer number, write a bit of code with a while()
loop to calculate the exponent! Do not use the exponent/hat ^
and using only the multiplication *
operator!
Part 2
Make a function from the code you wrote earlier with the following parameters:
name | Exp() |
params | base : the base of the expression |
ex : the exponent | |
return | The result. |