diff --git "a/TP3/Recursion/recursivit\303\251.py" "b/TP3/Recursion/recursivit\303\251.py" new file mode 100644 index 0000000000000000000000000000000000000000..85b0757259c23180cd212f3d3cdd51bff216af70 --- /dev/null +++ "b/TP3/Recursion/recursivit\303\251.py" @@ -0,0 +1,35 @@ +def somme_de_deux_nombres(a:int, b:int)->int: + """Renvoie la sommes des entiers + + Précondition : aucune + Exemple(s) : + $$$ somme_de_deux_nombres(100,200) + 300 + $$$ somme_de_deux_nombres(250,50) + 300 + """ + if a == 0 : + res = b + else: + res = somme_de_deux_nombres(a-1, b+1) + return res +#@trace +def binomial(n:int, p:int)->float: + """à_remplacer_par_ce_que_fait_la_fonction + + Précondition : n>=p + Exemple(s) : + $$$ binomial(5,2) + 10 + $$$ binomial(10,6) + 210 + + """ + res = 0 + if p == 0 or n==p: + res = 1 + else: + res = binomial(n-1,p) + binomial(n-1, p-1) + return res + + \ No newline at end of file