Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- def square_expo(x, n):
- if n == 0:
- return 1;
- if n % 2 == 0:
- return square_expo(x * x, n // 2)
- return x * square_expo(x * x, n // 2)
- x = int(input("x = "))
- n = int(input("n = "))
- print(square_expo(x, n))
Add Comment
Please, Sign In to add comment