Re: please i need explanation
On 11/01/2013 16:35, firstname.lastname@example.org wrote:
> def factorial(n):
> if n<2:
> return 1
> f = 1
> while n>= 2:
> f *= n
> f -= 1
> return f
What explanation this a function representing the math factorial.
You provide a parameter n:
if n est lower than 2 the factorial is 1 (return by the function).
in other case you multiply previous factoriel value by n (f *= n <=> f =
And you decrement n by 1 (f -=1 <=> f = f - 1).
This gives n*(n-)*(n-2).... general formula for factorial.
|All times are GMT. The time now is 06:16 PM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.