29 lines
452 B
C
29 lines
452 B
C
|
#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;
|
||
|
}
|