Advertisement
MasWag

1370.cc

Mar 11th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. /*
  7.   LCM
  8.   2568
  9.   7765
  10.  */
  11.  
  12. int
  13. gcd (int a, int b)
  14. {
  15.   while ( a != 0 ) {
  16.     b %= a;
  17.     swap (a,b);
  18.   }
  19.   return b;
  20. }
  21.  
  22. int
  23. main(void)
  24. {
  25.   const int g = gcd (2568,7765);
  26.   const int lcm = g * 2568 * 7765;
  27.  
  28.   printf ("%d\n",lcm);
  29.  
  30.   return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement