Logo

Programming-Idioms

History of Idiom 31 > diff from v63 to v64

Edit summary for version 64 by Lamanator:
[C++] Added missing semicolon.

Version 63

2020-10-13, 15:58:09

Version 64

2021-08-15, 20:40:29

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