Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Pow(x, n)
Bookmark
Brute Force
Recursive
Iterative
Input
2^10 (Even)
2.1^3 (Odd)
2^(-2) (Negative)
Custom
x
=
2
,
n
=
10
2
10
=
?
x =
2
power =
10
result =
1
result = 1 × x × … (0 / 10)
×x
×x
×x
×x
×x
×x
×x
×x
×x
×x
multiply the base 10 times: O(n)
2
10
=
?
x =
2
power =
10
result =
1
result = 1 × x × … (0 / 10)
×x
×x
×x
×x
×x
×x
×x
×x
×x
×x
multiply the base 10 times: O(n)
2
10
=
?
x =
2
power =
10
result =
1
result = 1 × x × … (0 / 10)
×x
×x
×x
×x
×x
×x
×x
×x
×x
×x
exponent is non-negative
2
10
=
?
x =
2
power =
10
result =
2
result = 1 × x × … (1 / 10)
×x
×x
×x
×x
×x
×x
×x
×x
×x
×x
step 1 of 10: result = 2
2
10
=
?
x =
2
power =
10
result =
4
result = 1 × x × … (2 / 10)
×x
×x
×x
×x
×x
×x
×x
×x
×x
×x
step 2 of 10: result = 4
2
10
=
?
x =
2
power =
10
result =
16
result = 1 × x × … (4 / 10)
×x
×x
×x
×x
×x
×x
×x
×x
×x
×x
step 4 of 10: result = 16
2
10
=
?
x =
2
power =
10
result =
32
result = 1 × x × … (5 / 10)
×x
×x
×x
×x
×x
×x
×x
×x
×x
×x
step 5 of 10: result = 32
2
10
=
?
x =
2
power =
10
result =
128
result = 1 × x × … (7 / 10)
×x
×x
×x
×x
×x
×x
×x
×x
×x
×x
step 7 of 10: result = 128
2
10
=
?
x =
2
power =
10
result =
256
result = 1 × x × … (8 / 10)
×x
×x
×x
×x
×x
×x
×x
×x
×x
×x
step 8 of 10: result = 256
2
10
=
?
x =
2
power =
10
result =
1024
result = 1 × x × … (10 / 10)
×x
×x
×x
×x
×x
×x
×x
×x
×x
×x
step 10 of 10: result = 1024
2
10
=
1024
x =
2
power =
10
result =
1024
result = 1 × x × … (10 / 10)
×x
×x
×x
×x
×x
×x
×x
×x
×x
×x
2^10 = 1024
algo
master
.
io
Step:
Compute 2^10 by multiplying the base repeatedly.
0 / 13
Input
2^10 (Even)
2.1^3 (Odd)
2^(-2) (Negative)
Custom
x
=
2
,
n
=
10
0 / 13
algo
master
.
io
Step:
Compute 2^10 by multiplying the base repeatedly.