On Mon, Dec 03, 2001 at 09:06:45PM +0800, Sacha Chua wrote:
> On 03 Dec 2001 01:43:57PM +0800, fooler ([EMAIL PROTECTED]) said:
> 
> > iterative:
> >     double factorial;
> >     if (n < 2) {
> >         factorial = 1;
> >     }else {
> >         for (factorial = n ; n != 2; factorial = factorial * --n);
> >     }
> 
> I don't know about you, but I'd have written the iterative factorial as:
> 
> int factorial = 1;
> for (i = 1; i <= n; i++)
>     factorial *= i;
> 
> cleaner, you think? ;)

Why bother with i==1?

:)

Michael
-- 
Michael Darrin Chaney
[EMAIL PROTECTED]
http://www.michaelchaney.com/
_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]

To subscribe to the Linux Newbies' List: send "subscribe" in the body to 
[EMAIL PROTECTED]

Reply via email to