FunctionRacerProblemsRace

Fast Power

MediumMathPython, JavaScript, TypeScript

Return x raised to the whole number power n (with n >= 0) using repeated squaring, so that only about log n multiplications are needed. Do not use ** or pow.

Example 1

x 3
n 4
returns 81

81.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems