Skip to content

Instantly share code, notes, and snippets.

@DaniloOliveira28
Created June 23, 2016 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DaniloOliveira28/8d5ca58350e72d7912b17ff81c522ced to your computer and use it in GitHub Desktop.
Save DaniloOliveira28/8d5ca58350e72d7912b17ff81c522ced to your computer and use it in GitHub Desktop.
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