Select Git revision
ppcm_bis.c 691 B
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
void main() {
int n = 15,m = 12;
printf("Entrez n et m:\n");
scanf("%d %d",&n,&m);
int tmp_n = n,tmp_m = m;
/*
while (tmp_n != tmp_m) {
if (tmp_n < tmp_m) {
tmp_n += n;
} else {
tmp_m += m;
}
}
while (true) {
if (tmp_n < tmp_m) {
tmp_n += n;
} else if (tmp_n > tmp_m) {
tmp_m += m;
} else {
break;
}
}
*/
do {
if (tmp_n < tmp_m) {
tmp_n += n;
} else {
tmp_m += m;
}
} while (tmp_n != tmp_m);
printf("Le ppcm de %d et %d est %d\n",n,m,tmp_m);
}