Logo

Programming-Idioms

History of Idiom 31 > diff from v45 to v46

Edit summary for version 46 by dingo:
New Csharp implementation by user [dingo]

Version 45

2019-07-06, 11:24:52

Version 46

2019-09-26, 13:46:32

Idiom #31 Recursive factorial (simple)

Create recursive function f which returns the factorial of non-negative integer i, calculated from f(i-1)

Idiom #31 Recursive factorial (simple)

Create recursive function f which returns the factorial of non-negative integer i, calculated from f(i-1)

Code
private static int Factorial(int n) {
    if (n == 0) return 1;
    return n * Factorial(n - 1);
}