Last active
December 18, 2015 07:39
-
-
Save phalt/5747825 to your computer and use it in GitHub Desktop.
Simple minimum function that can be used recursively
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 minimum(first, second): | |
# Returns the minimum | |
if first > second: | |
return sec | |
return first | |
#Test this | |
# print 5 | |
print minimum(5, 10) | |
# print 11 | |
print minimum(11, 20) | |
# Can be used recursively - prints 1 | |
print minimum(minimum(3,1), 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment