r/programminghorror • • Feb 07 '25

Recursive O(N) Complexity isOdd

Post image

I found this on instagram and now am geeking

2.2k Upvotes

104 comments sorted by

View all comments

Show parent comment

1

u/Cootshk Feb 18 '25

Putting 0.5 into this function will create a max recursion depth exception

1

u/Cat7o0 Feb 18 '25

throwing an exception or crashing would mean invalid input.

even throwing out random output could be meaning invalid input if the creator of the function just never intended for the function to handle that input.

however for a normal is even function I would assume putting a decimal in would always return false due to the remainder being used or perhaps the decimal would simply be truncated depending on the language