Sorry but this is not the spirit of recursion ;-)

by Lisztfr (no login)

Is recursion only the fact of calling one's self ? no... In that case it can be replaced by a loop.

I tried something like this before posting my code, like here : the counter was put inside the sub. This didn't make any sens.

My code here is a level beyond that :-) :

1) the counter is put inside the set of variables called by the sub (n)
2) the sub calls itself twice.

In fact circles are draw in 2 ^ n times. The recursion is true, it's not a loop... each time we have x 2 more circles. This is exponential calling.

If a function is calling it self, it also like f(n - 1).




Posted on Sep 28, 2010, 8:48 AM

Respond to this message   

Return to Index


Response TitleAuthor and Date
*Read about the Ackermann function on Oct 1