To understand recursion first you must understand recursion

A section to discuss matters not related to Chess in particular.
Arshad Ali
Posts: 704
Joined: Mon Feb 22, 2010 12:27 pm

Re: To understand recursion first you must understand recurs

Post by Arshad Ali » Sat Apr 09, 2011 1:27 am

E Michael White wrote: To get back to the thread title, an example of recursion is :-

1.ECF realise they have a cash shortage.
2.ECF make decision to raise game fee or introduce other measures
3.Fewer people play chess as a result
4.ECF has another cash shortage
5 Go to 1
This is iteration, commonly confused with recursion. The state variable, "cash position" keeps getting updated.

INT Game fee, cash position;
BOOL close;
WHILE cash position < ideal AND cash position != 0
Game fee = Game Fee + 10;
IF cash position = 0
ECF close;
ELSE cash position >= ideal
RETURN 0;