37 lines
954 B
Markdown
37 lines
954 B
Markdown
{
|
|
R : Calcule le plus grand diviseur commun entre 2 entier a et b
|
|
E : a et b, 2 entiers positifs
|
|
S : un entier correspondant au plus grand diviseur commun de a et b
|
|
}
|
|
pgcd: une fonction (a: un entier, b un entier) -> un entier
|
|
Lexique : {Local à pgcd}
|
|
r : un entier
|
|
Algorithme : {Local à pgcd}
|
|
Début
|
|
Tant Que b != 0
|
|
r <- a reste b
|
|
a <- b
|
|
b <- r
|
|
Fin Tant Que
|
|
Retourner(a)
|
|
Fin
|
|
|
|
Lexique : {Principal}
|
|
{R : ...; E : ...; S : ...}
|
|
pgcd: une fonction (a: un entier, b un entier) -> un entier
|
|
|
|
a : un entier
|
|
b : un entier
|
|
plusGrandDiviseur : un entier
|
|
Algorithme : {Principal}
|
|
Début
|
|
Ecrire("Entrez a un entier positif")
|
|
Lire(a)
|
|
|
|
Ecrire("Entrez b un entier positif")
|
|
Lire(b)
|
|
|
|
plusGrandDiviseur <- pgcd(a, b)
|
|
|
|
Ecrire("Le plus grand diviseur commun de ", a, " et ", b, " est ", plusGrandDiviseur)
|
|
Fin |