Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36612

Re: please i need explanation

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!hq-usenetpeers.eweka.nl!81.171.88.15.MISMATCH!eweka.nl!lightspeed.eweka.nl!194.134.4.91.MISMATCH!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <kliateni@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.045
X-Spam-Evidence '*H*': 0.91; '*S*': 0.00; 'parameter': 0.07; 'explanation': 0.09; 'def': 0.10; '1).': 0.16; 'formula': 0.16; 'function).': 0.16; 'wrote:': 0.17; 'subject:need': 0.17; 'math': 0.20; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'subject:please': 0.27; 'function': 0.30; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'message-id:@gmail.com': 0.36; 'previous': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'lower': 0.61; 'provide': 0.62; 'skip:n 10': 0.63; 'email addr:gmail.com': 0.63; 'multiply': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type; bh=9Whx++m9cWBir2/t2mkHOOJdmKMfnwGQPJ+a8zzIUPE=; b=WlAvxGQo3Ed8EzsP1OoiktctJ5ELto4fHu9UqjakF2gzkdtWHlUM46Ns1MZnX1184Z yMUNUWC6laD7Y3ZExhJvV2AIWsZ8ki4CF3P03E9hyNjVP8mpfjan5a1wt2KAlBCwfsvv nnNUhYj9BjU2tAM8ntF6cKrWAvp+Kl9oIrUphRhFGSzEnumCjdJRGsB/IiPXJDp+erBY oJAEQu/lsCfm2Ba12mi0aNAgse3gfQc0EoPc6b5MD3UnpjO1P4424HgtVQAAAG7MC/uV BIlhQuuc0YLFyZVudqUujZccPypjl0wwXJtFvOK5PaPfMoYf5dqymYmATsLmKJ/8kAUP KAXQ==
X-Received by 10.112.51.175 with SMTP id l15mr29839862lbo.5.1357898378418; Fri, 11 Jan 2013 01:59:38 -0800 (PST)
Date Fri, 11 Jan 2013 10:59:30 +0100
From Karim <kliateni@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version 1.0
To python-list@python.org
Subject Re: please i need explanation
References <2FB5A66FD91D456BBDFCC0AE25760392@favour>
In-Reply-To <2FB5A66FD91D456BBDFCC0AE25760392@favour>
Content-Type multipart/alternative; boundary="------------000305030409040003010301"
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.391.1357898744.2939.python-list@python.org> (permalink)
Lines 78
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357898744 news.xs4all.nl 6971 [2001:888:2000:d::a6]:44982
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36612

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 11/01/2013 16:35, kwakukwatiah@gmail.com 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 = 
f *n).
And you decrement n by 1 (f -=1 <=> f = f - 1).
This gives n*(n-)*(n-2).... general formula for factorial.

Regards
Karim

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: please i need explanation Karim <kliateni@gmail.com> - 2013-01-11 10:59 +0100

csiph-web