Skip to content
Snippets Groups Projects
Select Git revision
  • bf4583cd77ebacd8ad01cbc3dd6ee2bef1f8b024
  • main default protected
2 results

ppcm_bis.c

Blame
  • 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);
    }