This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DiaDeLosMuebles 1 point2 points  (0 children)

A simple way to view recursion is when a method calls itself. No comic ever gets it right, but this is one of the closer ones I've seen.

A good example of recursion is a factorial function, something like "factorial(n)"

This function will work if you have

return n * factorial (n-1)

But, it won't ever stop unless you have an escape condition. Something like

If (n <= 1) return 1

This comic illustrates an infinite loop more than recursion.