[Tutor] factorialProcess
David Broadwell
dbroadwell@mindspring.com
Mon May 12 23:54:02 2003
Mic Forster Wrote;
> All that is required is the final value. Does anyone know how to do this?
> # And heres the third attempt with the correct output.
Warning untested code;
Origin:
>>> def fac(x):
b, count = 1, 1
while count < x:
print b,
b = b*(count+1)
count = count + 1
Ah, you printing on every iteration. B will exist outside the scope of your
while ... so let's move that print line.
Correction;
>>> def fac(x):
''' Factorials and INT, prints and returns it '''
b, count = 1, 1
while count < x:
b = b*(count+1)
count = count + 1
print b
return b
--
David Broadwell