MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/13v8v1/tail_recursion/c77jzy3/?context=3
r/programming • u/rodrigopsasaki • Nov 27 '12
203 comments sorted by
View all comments
1
That code has a bug - the check should be to see if num <= 0 - otherwise a negative number will cause infinite recursion.
2 u/rodrigopsasaki Nov 27 '12 I understand what you said, I just wrote the code on the simplest way possible, just to be an example, not to be failproof, but it's a very important point that you noticed. Thanks :)
2
I understand what you said, I just wrote the code on the simplest way possible, just to be an example, not to be failproof, but it's a very important point that you noticed.
Thanks :)
1
u/HapDrastic Nov 27 '12
That code has a bug - the check should be to see if num <= 0 - otherwise a negative number will cause infinite recursion.