Recursive Positive Number Check
>>> def isPositive(number): try: if(number - 1 == 0): return True else: return isPositive(number - 1) except: return False >>> isPositive(30) True >>> isPositive(0) False >>> isPositive(-100) False >>> isPositive(100) True
A Python REPL shows a recursively defined function checking whether a number is positive. The joke is that the function works for positive inputs by counting down recursively, but incorrectly returns false for zero and negative values, presenting flawed code as a cringe programming example.
- @dev_meme / 1476 2020-05-02
- Type
- image
- Size
- 344×278 · 14.6 KiB
- Mood
- cringe, sarcastic
- Language
- en
- Added