Calculating factorial
Olli Rajala
ollir at linuxfreak.com
Mon Dec 4 10:48:23 EST 2000
Hi!
I've learned a few time Python and programming. I wrote a function
that calculates a factorial of N and I was wondering if it's the best
(I think it's not. =) way to do that. I'm glad to hear your comments.
<script>
def factorial(f):
result = 1
for number in range(1, f + 1):
result = result * number
return result
print factorial(10)
</script>
Ps. Sorry my poor English.
--
Olli Rajala
A Finnish student who loves Linux.
More information about the Python-list
mailing list