In C language, recursion is a procedure that you call repeatedly. This function has recursive function queries. A function call of sorts is called a recursive call.
Program
using System; class HelloWorld { static void Main() { HelloWorld hw = new HelloWorld(); Console.WriteLine('Sum : ' + hw.add(10)); }
int add(int digit){ int sum = 0; if(digit == 0) return 0; sum = digit + this.add(digit - 1); Console.Write('{0}, ',digit); return sum; } }
Output
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, Sum : 55
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Recursive function
In C language, recursion is a procedure that you call repeatedly. This function has recursive function queries. A function call of sorts is called a recursive call.
Program
Output