Um any function that calls itself IS recursion. In fact there are two recursion points in that function.

07-24-2004

Maragato

Quote:

Originally Posted by Thantos

Um any function that calls itself IS recursion. In fact there are two recursion points in that function.

Can you please me point them cause I see just one? :confused:

07-24-2004

sean

Code:

p(n-2)
...
p(n-1)

07-24-2004

Maragato

Quote:

Originally Posted by sean_mackrory

Code:

p(n-2)
...
p(n-1)

Wow I should be drunk when I posted before, sorry dude now I got it:eek:

07-25-2004

viaxd

it's strange that people first learn recursion by writing the factorial function, it's simple, but terribly inefficient and really a poor use of recursion and it's capabilities. Recursion is better used in text analysis, sorting and data structure manipulation.

07-25-2004

Robc

>it's strange that people first learn recursion by writing the factorial function
Not strange at all really. As you said, it's simple and easy to trace. That makes it a good candidate for a first step into the concept of recursion. The same goes with the fibonacci recursive solution. Neither of them should be used in any real code, but they're a critical step for beginners.