fork download
  1. #include <stdio.h>
  2. int UCNN(int a,int b){
  3. while (b != 0)
  4. {
  5. int temp = a % b;
  6. a = b;
  7. b = temp;
  8. }
  9. return a;
  10. }
  11. int main(){
  12. int t,i=0;
  13. int a,b;
  14. scanf("%d",&t);
  15. while((i++)<t){
  16. scanf("%d%d",&a,&b);
  17. printf("\nLCM(%5d,%5d) = %5d",a,b,a*b/UCNN(a,b));
  18. }
  19.  
  20. }
  21.  
Success #stdin #stdout 0s 9432KB
stdin
2
1 5
6 4
stdout
LCM(    1,    5) =     5
LCM(    6,    4) =    12