Go back to previous page
Forum URL: http://www.cut-the-knot.org/cgi-bin/dcforum/forumctk.cgi
Forum Name: College math
Topic ID: 8
Message ID: 5
#5, RE: flavius recurrsion error (I think)
Posted by Katherine on Oct-31-00 at 12:36 PM
In response to message #3
Dear Sir:

Here is a recursive algorithm J(n) I came up with for my m=2 notation (your m=3):

n = number of players
J(n-1) = previous player's winner (the recursive call to this algorithm)
w = winner


if (n=0) then w = 0 else
if (n=1) then w = 1 else
if (J(n-1)==n-1) then w = 2 else
if (J(n-1)==n-2) then w = 1 else w = J(n-1)+3

Even though the recursive call shows up 3 times in the algorithm, I just call it once and use the value returned in the evaluations statements.

Thanks,
katherine