First commit
This commit is contained in:
37
IUT/Info1/TD/Exercices/8.5_PGCD/8.5.md
Normal file
37
IUT/Info1/TD/Exercices/8.5_PGCD/8.5.md
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
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
|
||||
Reference in New Issue
Block a user