LANGUAGE

Recursive function

A self-calling helper with a terminating base case and progress condition.

Formal Syntax & Structure

csharp syntaxcsharp
if (baseCase) return result; return Name(smallerInput);

Working Example

Example Snippetcsharp
static int Sum(int n) => n == 0 ? 0 : n + Sum(n - 1);
C# & .NET Reference