This program http://code.geeksforgeeks.org/cTn5HI is finding Grundy Numbers using recursion and memoization . Can you please explain me the recusion part of this program means like in line number 41 to whom return(Grundy[n]) is returning everytime.
It is returning Grundy[n] because first we are storing the answer in Grundy[n]. So this just returns the answer. This storing is done so as to save ourselves from not calculating this value again and again.
I don’t have enough Karma to ask questions. What should I do?
We are storing just the answer for every recursion in Grundy and returning it . At the same time , Storing the answer in Grundy helps us to use this value whenever needed by memoizing it . So , Grundy[n] returns the answer to your recursion .
P.S. :- do upvote my answer ... i need to ask some questions as well but don't have enough karma
Hey , i don't have enough karma to ask questions . I am a newbie .
There you are.