Created
May 9, 2012 19:12
-
-
Save sigmavirus24/2648112 to your computer and use it in GitHub Desktop.
Studying Fun
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 gcd(a, b): | |
if a < b: | |
(a, b) = b, a | |
print euclidean_algorithm(a, b) | |
def euclidean_algorithm(a, b): | |
r = a % b | |
if r: | |
return euclidean_algorithm(b, r) | |
return b | |
# Was studying for a final exam for number theory | |
# and realized how simple this algorithm would be |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment