.bo484849ade { font-family: system-ui; background-color: #f4f4f4; margin: 0; padding: 0; } .bo484849a { max-width: 600px; margin: 50px auto; padding: 20px; background: white; border-radius: 10px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } .titre-centre { text-align: center; color: #333; } .exercice-484849a, .solution-484849a { border: 1px solid #ddd; padding: 15px; margin: 20px 0; border-radius: 8px; background-color: #fafafa; } .exercice-484849a h2, .solution-484849a h2 { margin-top: 0; color: #007BFF; } input[type="number"] { width: calc(50% - 10px); padding: 10px; margin: 10px 5px; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; } .bouton-484849a { padding: 10px 20px; background-color: #007BFF; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; transition: background-color 0.3s; } .bouton-484849a:hover { background-color: #0056b3; } #resultat-484849a { margin-top: 20px; font-size: 18px; text-align: center; color: #333; }

Calcul du PGCD (Algorithme d\'Euclide)

Exercice

Entrez deux nombres pour calculer leur PGCD :

Algorithme d\'Euclide

Principe de l\'algorithme :

PGCD(a, b) = PGCD(b, a % b)
Si b = 0 alors PGCD(a, b) = a
        

Algorithme :

Fonction PGCD(a, b)
Début
    Tant que b ≠ 0 faire
        temp = b
        b = a % b
        a = temp
    Fin Tant que
    Retourner a
Fin
        

Explication :

Voici comment fonctionne l\'algorithme d\'Euclide pour calculer le PGCD :

Pour calculer PGCD(48, 18) :

1. PGCD(48, 18) : 48 % 18 = 12, donc PGCD(18, 12)

2. PGCD(18, 12) : 18 % 12 = 6, donc PGCD(12, 6)

3. PGCD(12, 6) : 12 % 6 = 0, donc PGCD(6, 0)

4. Comme b = 0, PGCD(6, 0) = 6.

Le PGCD de 48 et 18 est donc 6.

'; ?>