Logo

Programming-Idioms

History of Idiom 31 > diff from v61 to v62

Edit summary for version 62 by OC:
New Obj-C implementation by user [OC]

Version 61

2020-07-02, 22:15:46

Version 62

2020-10-10, 20:40:26

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)

Variables
f,i
Variables
f,i
Code
unsigned f(unsigned i) {
  return i?i*f(i-1):1;
}
Comments bubble
Precisely same as plain C