[TP3] Exercice 3

This commit is contained in:
Suwako Moriya 2019-11-23 18:23:24 +01:00
parent 3f0e3874b7
commit 02c92aedeb
Signed by: SuwakoMmh
GPG Key ID: A27482B806F13CD5

View File

@ -99,3 +99,22 @@ def uq(n, q):
#Exercice 3
#1, a)
def fact(n):
res=1
for i in range(2,n+1):
res *= i
return res
#1, b)
def binome(n, p):
return fact(n)/(fact(p)*(fact(n-p)))
#2
def binomes(n):
lastl=[1, 0]
for i in range(n+1):
l = [1]
for j in range(i):
l.append(lastl.pop(0) + lastl[0])
lastl=l+ [0]
return(l)