11 Octobre
This commit is contained in:
29
DEV1.1/TP05:Boucles/Boucles:suite/Boucles:encore/diviseur.c
Normal file
29
DEV1.1/TP05:Boucles/Boucles:suite/Boucles:encore/diviseur.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
int d;
|
||||
int e;
|
||||
printf("Veuillez saisir 2 entiers naturels : ");
|
||||
scanf("%d",&a);
|
||||
scanf(" %d",&b);
|
||||
if (b>a){
|
||||
c=a;
|
||||
a=b;
|
||||
b=c;
|
||||
}if(b==0){
|
||||
printf("Le pgcd entre %d et %d est de %d\n",a,b,a);
|
||||
}else{
|
||||
d=a;
|
||||
e=b;
|
||||
while(d!=0&&e!=0){
|
||||
c=d;
|
||||
d=e;
|
||||
e=c%e;
|
||||
} printf("Le pgcd entre %d et %d est de %d\n",a,b,d);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user