Default Power
You are given an integer N and optionally an integer EXP.
Create a function named power that:
- Takes two integers N and EXP as parameters. where N is fixed parameter and EXP is optional
- Returns a integer, n raised to the power EXP
- If EXP is not provided, use the default value 2
Note: For custom input provide EXP as -1 if you do not want to EXP to have any value
Example 1:
Input: N = 2, EXP = 4
Output: 16
Example 2:
Input: N = 2, EXP = -1
Output: 4
Explanation:
Here EXP is given as -1, so we need to consider the default value of EXP i.e. 2.
So NEXP = 22 = 4
Now Your Turn!
Pick the correct output for the given inputInput: N = 10, EXP = -1
Still unsure what the problem is asking ?
Letโs go through a few more examples, step by step, to make it clearer.
Constraints:
- 0 <= N <= 100
- -1 <= EXP <= 10
- NEXP <= 107