Logo

Programming-Idioms

History of Idiom 31 > diff from v26 to v27

Edit summary for version 27 by :
New Cpp implementation by user [everyday847]

Version 26

2016-02-17, 17:00:00

Version 27

2016-02-17, 18:00:11

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
unsigned int f( unsigned int i ) {
	if ( i == 0 ) return 1;
	
	return i * f( i - 1 )
}