Compute a^b iteratively:
<code>int p = 1; for (int i = 0; i < b; i++) p *= a; </code></pre> For a=3, b=4, p is
- A
7
- B
12
- Ccheck_circle
81
- D
27
Explanation
3⁴ = 81.
AP Computer Science A· difficulty 4/5
Compute a^b iteratively:
<code>int p = 1; for (int i = 0; i < b; i++) p *= a; </code></pre> For a=3, b=4, p is
7
12
81
27
Explanation
3⁴ = 81.
Want 10 more like this — adaptive to your weak spots?