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


Groups > comp.lang.python > #36615

Re: please i need explanation

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!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.042
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; "'return": 0.09; '(instead': 0.09; 'explanation': 0.09; 'friday,': 0.09; 'cc:addr :python-list': 0.10; 'def': 0.10; 'wrote:': 0.17; 'message-----': 0.17; 'subject:need': 0.17; 'work.': 0.23; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'question': 0.27; 'subject:please': 0.27; 'correct': 0.28; 'maybe': 0.29; 'code': 0.31; 'skip:- 10': 0.32; '11,': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'subject:': 0.36; 'but': 0.36; 'message-id:@gmail.com': 0.36; 'totally': 0.36; 'email addr:python.org': 0.36; 'should': 0.36; 'why': 0.37; 'sent:': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'from:': 0.38; 'sure': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'email name:python-list': 0.62; 'different': 0.63; 'skip:n 10': 0.63; 'email addr:gmail.com': 0.63; 'charset:windows-1252': 0.65; 'below.': 0.68; 'stated': 0.69; '2013': 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:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=Skqzx8pUTpmeqRSERW/BwFZF5SplODn01uDFd/8/zTw=; b=dGNvKYyhSnfKCrzZVaYqjY+jgHdhfdOq51GgVx8gry+2E6+ZgGxyuW93W5xPreoFk+ 4mOVO1DdOhOdKVOD9keSypDq1qEzmUw0spuD6EG7pSBzkwLTuunQf0tFYjWJht+xeC+E 5EqdexFXw7090Qx7gSHguVRaDRoeLGteCPDhK+j/cHqgo9Dd50wHn8lbzCUqQvXFvtUv TK5aWOdbPedw3SQTKLtQcFj5+cTD0rLXCRuZzkAYkg/G2J434CGzw0eU4X3jAPfSf4Ut BiAaiz7UwC4dJ+9O8+JiuS8eFNNbgxaw1bS7zklkyDmbICPlsiZTvaPS53UqlVhdhh5V fHQg==
X-Received by 10.152.147.36 with SMTP id th4mr66043407lab.44.1357900912176; Fri, 11 Jan 2013 02:41:52 -0800 (PST)
Date Fri, 11 Jan 2013 11:41:42 +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 kwakukwatiah@gmail.com
Subject Re: please i need explanation
References <2FB5A66FD91D456BBDFCC0AE25760392@favour> <50EFE1C3.5000303@nic.fi> <E34A7B5E52A64FEAA32CB66A8CA7AC7A@favour>
In-Reply-To <E34A7B5E52A64FEAA32CB66A8CA7AC7A@favour>
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 8bit
Cc python-list@python.org
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.394.1357900919.2939.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357900919 news.xs4all.nl 6866 [2001:888:2000:d::a6]:60071
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36615

Show key headers only | View raw


On 11/01/2013 17:33, kwakukwatiah@gmail.com wrote:
>
>
> -----Original Message----- From: K. Elo
> Sent: Friday, January 11, 2013 3:56 AM
> To: python-list@python.org
> Subject: Re: please i need explanation
>
> Hi!
>
> Since there is no stated question, I need to guess:
>
> n -= 1 (instead of "f -= 1")
>
> should work.
>
> Or maybe the question was a totally different one...
>
> -Kimmo
>
> 11.01.2013 17:35, kwakukwatiah@gmail.com wrote:
>> def factorial(n):
>> if n<2:
>> return 1
>> f = 1
>> while n>= 2:
>> f *= n
>> f -= 1
>> return f
>>
>>
>>
> please it works.but don’t get why the return 1 and the code below.
>
factorial or n! = n*(n-1)*(n-2).... for n > 1. For n = 0, 1 the 
factorial is 1 the reason for the 'return 1'.

f *= n <=> f = f* n
f -= 1 <=> f = f - 1 but sure this is not correct as Kimmo said n = n - 
1 or n -= 1

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 11:41 +0100

csiph-web