richie3366

ppcm v1

Oct 3rd, 2012
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 0.77 KB | None | 0 0
  1. ----------------------------------------------------------------
  2. --  *  ppcm.adb
  3. --  *  Role : trouver le PPCM de deux nombres.
  4. ----------------------------------------------------------------
  5. with entrees_sorties; use entrees_sorties;
  6.  
  7. procedure ppcm is
  8.     nb1, nb2 : Integer;
  9.     multiplieur : Integer;
  10.     ppcm : Integer;
  11. begin
  12.    
  13.     ppcm := -1;
  14.     multiplieur := 1;
  15.        
  16.     put("a ? ");
  17.     get(nb1);
  18.     new_line;
  19.    
  20.     put("b ? ");
  21.     get(nb2);
  22.     new_line;
  23.    
  24.     if(nb1 <= 0 OR nb2 <=0) then
  25.         ppcm := 0;
  26.     end if;
  27.    
  28.     while(ppcm < 0) loop
  29.        
  30.         if(((nb1*multiplieur) mod nb2) = 0) then
  31.             ppcm := nb1*multiplieur;
  32.         end if;    
  33.        
  34.         multiplieur := multiplieur + 1;
  35.     end loop;
  36.    
  37.     put("PPCM(");
  38.     put(nb1, 0);
  39.     put(", ");
  40.     put(nb2, 0);
  41.     put(") = ");
  42.     put(ppcm, 0);  
  43.    
  44. end ppcm;
Advertisement
Add Comment
Please, Sign In to add comment