[Tutor] factorial

Gerrit Holl gerrit@nl.linux.org
Sun May 11 04:40:13 2003


> From: Mic Forster <micforster@yahoo.com>
> To: tutor@python.org
> Subject: [Tutor] factorial
> Date: 	Sun, 11 May 2003 10:10:41 +0200

> Hi Chaps,

Hi,

> Does Python support a factorial function?
> 
> eg.(below is math notation)
> n = 10
> y = 3
> x = n! / y! - 1
> x = ?

As I understand it, you can easily write it yourself:

 16 >>> def fact(n):
 16 ...  if n<2: return n
 16 ...  else: return n*fact(n-1)
 16 ...
 18 >>> fact(10)/fact(3) - 1
604799

Or is that not what you mean?

yours,
Gerrit.

-- 
124. If any one deliver silver, gold, or anything else to another for
safe keeping, before a witness, but he deny it, he shall be brought before
a judge, and all that he has denied he shall pay in full. 
        -- Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/