Re: Iteration for Factorials
In article <1193261568.712 027.234520@e9g2 000prf.googlegr oups.com>,
"mensanator@aol .com" <mensanator@aol .comwrote:
>
Simple minded indeed.
>
0.0
>
Whoops, should have xrange(i)+1 there. Or, better, xrange(2,n+1). Save a
multiplication. Just trying to show the OP the scheme for iteration
here.
--
-- Lou Pecora
In article <1193261568.712 027.234520@e9g2 000prf.googlegr oups.com>,
"mensanator@aol .com" <mensanator@aol .comwrote:
def factorial(i):
fact=1.0
for n in xrange(i):
fact=n*fact
return fact
fact=1.0
for n in xrange(i):
fact=n*fact
return fact
Simple minded indeed.
>
>factorial(3)
>
multiplication. Just trying to show the OP the scheme for iteration
here.
--
-- Lou Pecora
Comment