def square(x):
return x * x
def twoPower(x, n):
while n > 1:
x = square(x)
n = n/2
return x
twoPower(2, 8)
gives 256 when we bind x = 5, n = 1. Why?
def square(x):
return x * x
def twoPower(x, n):
while n > 1:
x = square(x)
n = n/2
return x
twoPower(2, 8)
gives 256 when we bind x = 5, n = 1. Why?