How do you learn to use recursion?
int fact(int a)
{
if(a==1)
return 1;
return a*fact(a-1);
}
Tags: recursion computer-science
Source: By Mike Minutillo as answer to the question
This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 2.5
Related code-snippets:
- What is tree walking? Expression evaluation and expression evaluation?
- What are lambda?
- What should be done to speed up recursion and memory?
- How do I find the number of.exe files, in all subdirectories of a particular subdirectory?
- What is tail recursion?
- How can you set your time for what your "things done" number means on a recursive algorithm in Java?
- How do you get the last record generated in recursive CTE?
- What is a closed space?
- Can Ruby convert acts_as_nested_set to a JSON hash cleanly?
- Recursive function for xml files (hierarchial data) and recursive function for xml file.
- Recursive lambda expression to traverse a tree in C#.
- Are recursion and iteration good alternatives?
- What is future?