Skip to content

Instantly share code, notes, and snippets.

@jakedobkin
Created January 1, 2012 04:41
Show Gist options
  • Save jakedobkin/1546271 to your computer and use it in GitHub Desktop.
Save jakedobkin/1546271 to your computer and use it in GitHub Desktop.
Project Euler 97
# this is the simplest way- show all but the last 10 digits
print str(28433*pow(2,7830457)+1)[2357197:]
# which is equivalent to
print (28433 * 2**7830457 + 1) % 10000000000
# which is equivalent to
print (28433 * pow(2, 7830457) + 1) % 10**10
# which is equivalent to
print (28433 * pow(2, 7830457)) % 10**10 +1
# with three arguments, pow is equivalent to (x**y) % z
# but i don't understand this exactly
print (28433 * pow(2, 7830457, 10**10)) % 10**10 +1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment