BTS | Mathématiques | Durée : 40 min | /20
Dernière mise à jour : 21 juin 2026
Nom : _____ Prénom : _____ Date : _____
On exécute l'algorithme suivant :
a ← 3
b ← 5
a ← a + b
b ← a - b
Afficher(a, b)
On considère l'algorithme :
somme ← 0
POUR i DE 1 A 4 FAIRE
somme ← somme + i * i
FIN POUR
Afficher(somme)
Donner la valeur affichée, en détaillant le calcul. (3 pts)
On rappelle la factorielle récursive : \(\text{Fact}(n) = n \times \text{Fact}(n-1)\) avec \(\text{Fact}(0) = 1\).
On cherche \(\sqrt{2}\) en résolvant \(f(x) = x^2 - 2 = 0\) par Newton-Raphson : \(x_{n+1} = x_n - \dfrac{f(x_n)}{f'(x_n)}\), avec \(f'(x) = 2x\) et \(x_0 = 1\).
Exercice 1 (4 pts)
a) Suivi des affectations (l'affectation écrase l'ancienne valeur) :
(3 pts)
b) Le couple affiché est \((8, 3)\). (1 pt)
Exercice 2 (3 pts)
La boucle ajoute \(i^2\) pour \(i = 1, 2, 3, 4\) : \[\text{somme} = 1^2 + 2^2 + 3^2 + 4^2 = 1 + 4 + 9 + 16 = 30\] La valeur affichée est \(30\). (3 pts)
Exercice 3 (4 pts)
a) \(\text{Fact}(4) = 4 \times \text{Fact}(3) = 4 \times 3 \times \text{Fact}(2) = 4 \times 3 \times 2 \times \text{Fact}(1) = 4 \times 3 \times 2 \times 1 = 24\). (2 pts)
b) \(F_2 = 1+0 = 1\) ; \(F_3 = 1+1 = 2\) ; \(F_4 = 2+1 = 3\) ; \(F_5 = 3+2 = 5\) ; \(F_6 = 5+3 = 8\). Soit \(1, 2, 3, 5, 8\). (2 pts)
Exercice 4 (5 pts)
a) \(x_{n+1} = x_n - \dfrac{x_n^2 - 2}{2x_n} = x_n - \dfrac{x_n}{2} + \dfrac{2}{2x_n} = \dfrac{x_n}{2} + \dfrac{1}{x_n}\). (2 pts)
b) Avec \(x_0 = 1\) : \[x_1 = \dfrac{1}{2} + \dfrac{1}{1} = \dfrac{3}{2} = 1{,}5\] \[x_2 = \dfrac{3/2}{2} + \dfrac{1}{3/2} = \dfrac{3}{4} + \dfrac{2}{3} = \dfrac{9}{12} + \dfrac{8}{12} = \dfrac{17}{12} \approx 1{,}41667\] On approche bien \(\sqrt{2} \approx 1{,}41421\). (3 pts)
Exercice 5 (4 pts)
a) Du plus rapide au plus lent : \(O(\log n) \ll O(n) \ll O(n\log n) \ll O(n^2)\). (2 pts)
b) Tri à bulles, pire cas : \(O(n^2)\). Recherche par dichotomie : \(O(\log n)\). (2 pts)
Total : 4 + 3 + 4 + 5 + 4 = 20 points.