Faculty of 0 (was: Re: reentrant vs. non-reentrant code)

Leo de Wit leo at philmds.UUCP
Wed Aug 3 21:57:10 AEST 1988


In article <4790 at pasteur.Berkeley.EDU> anton at postgres.UUCP (Jeff Anton) writes:
|/* recursive and reentrant */
|unsigned
|fact1(i)
|unsigned i;
|{
|	if (i < 3)
|		return(i);
|	return (i*fact1(i-1));
|}

And roy at phri.UUCP (Roy Smith) writes in his article:
|	fact (i)
|	int i;
|	{
|		return (i<2 ? i : i*fact(i-1));
|	}

Both are obviously implementing a faculty function; note that the faculty
of 0 is 1, not 0.

                   Leo.



More information about the Comp.unix.wizards mailing list