[TP3] Exercice 3
This commit is contained in:
parent
3f0e3874b7
commit
02c92aedeb
19
TP3/main.py
19
TP3/main.py
@ -99,3 +99,22 @@ def uq(n, q):
|
|||||||
|
|
||||||
|
|
||||||
#Exercice 3
|
#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)
|
Loading…
Reference in New Issue
Block a user