Logo

Programming-Idioms

History of Idiom 31 > diff from v13 to v14

Edit summary for version 14 by :

Version 13

2015-09-04, 15:45:00

Version 14

2015-09-04, 15:56: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)

Code
unsigned int f(unsigned int i)
{
	return i?i*f(i-1):1;
}
Code
unsigned int f(unsigned int i)
{
	return i?i*f(i-1):1;
}
Comments bubble
Overflows for i > 20 in 64bits and for i > 12 in 32bits