Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int NWD(int a, int b)
  6. {
  7. while(a!=b)
  8.  
  9. if(a>b)
  10.  
  11. a=a-b;
  12.  
  13. else
  14.  
  15. b=b-a;
  16.  
  17. return a;
  18. }
  19.  
  20. int main()
  21. {
  22. int g_1=0, g_2=0;
  23. int attempts;
  24.  
  25. cin>>attempts;
  26.  
  27. for (int i=0; i<attempts; i++)
  28. {
  29.  
  30. cin>>g_1;
  31. cin>>g_2;
  32.  
  33. cout<<g_1/NWD(g_1, g_2)*g_2;
  34. }
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement