Unit 2 Task 42: Powers by repeated multiplication

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Unit 2 Task 42 - Powers by repeated multiplication

← Unit 2 tasks · Solution


Ask for base (int) and exponent (non-negative int). Compute base^exponent using a loop and multiplication only (do not use ** or pow).

Note: Anything to the power 0 is 1.

Skills: for or while, edge case exponent 0.