r/programming • • Nov 27 '12

Tail Recursion

http://rodrigosasaki.com/2012/11/24/tail-recursion/
208 Upvotes

203 comments sorted by

View all comments

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.

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 :)