-
-
Save DaniloOliveira28/8d5ca58350e72d7912b17ff81c522ced to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def exp(a, n): | |
if n <= 0: | |
return 1 | |
if n % 2 == 0: | |
return exp(a, n / 2) * exp(a, n / 2) | |
else: | |
return exp(a, (n - 1) / 2) * exp(a, (n - 1) / 2) * a | |
if __name__ == '__main__': | |
print exp(10, 1023) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment