diff --git a/Exercice2.md b/Exercice2.md new file mode 100644 index 0000000..1f30717 --- /dev/null +++ b/Exercice2.md @@ -0,0 +1,16 @@ +**Calculs de complecité de fonctions** + +- Function_1 + - Complexité = 1 + - O(n×m) + + +- Function_2 + - Complexité = 1 + - O(n) + +- Function_3 + - Complexité = 1 + - O(n) + + diff --git a/Exercice3.md b/Exercice3.md new file mode 100644 index 0000000..e69de29 diff --git a/fonctions.py b/fonctions.py new file mode 100644 index 0000000..668c343 --- /dev/null +++ b/fonctions.py @@ -0,0 +1,29 @@ +def function(tableau1, tableau2): + presentDansDeuxListes = 0 + for nombre1 in tableau1: + for (nombre2 in tableau2): + if (nombre1 == nombre2): + presentDansDeuxListes += 1 + break + return presentDansDeuxListes + + +def funtion_2(x): + valeur = 0 + while (x > 0): + valeur = valeur + x + x -= 1 + return valeur + + +def function_3(x): + valeur = 0 + + if (x < 0): + valeur = -x + if (x == 0): + pass + if (x > 0): + valeur = x + return valeur +