You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Understand what the interviewer is asking for by using test cases and questions about the problem.
Will exponent always be positive?
Yes, you can assume both base and exponent are positive integers.
P-lan
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Create a function that takes parameters base and exponent and uses repeated multiplication to calculate the exponent.
1) Create a variable to store the running total
2) By default, set the total to be the same as `base`3) Loop `exponent - 1` times, and each time multiply the total by the base
4) Return the total variable