Created
November 20, 2021 20:28
-
-
Save RyanNutt/d495123adc39e92423cf4119360fa96c to your computer and use it in GitHub Desktop.
Recursive is_odd. Not something to actually use, but will probably talk about this in class as an example for recursion. https://www.reddit.com/r/ProgrammerHumor/comments/qyb5ut/odd/
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 is_odd(num): | |
if k == 1: | |
return True | |
elif k == 0: | |
return False | |
elif (num < 0): | |
return is_odd(num * -1) | |
else: | |
return is_odd(num - 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment