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


Groups > comp.lang.python > #36615 > unrolled thread

Re: please i need explanation

Started byKarim <kliateni@gmail.com>
First post2013-01-11 11:41 +0100
Last post2013-01-11 11:41 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#36615 — Re: please i need explanation

FromKarim <kliateni@gmail.com>
Date2013-01-11 11:41 +0100
SubjectRe: please i need explanation
Message-ID<mailman.394.1357900919.2939.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web