Programming-Idioms

History of Idiom 31 > diff from v29 to v30

Edit summary for version 30 :
New PHP implementation by user [AgillaDev]

Version 29

2016-02-18, 17:22:31

Version 30

2016-02-19, 14:58:25

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
function factorial($num) {
	if($num == 0) {
		return 1;
	}
	else {
		return ($num * factorial($num-1));
	}
}