Advertisement
nyker

Untitled

Apr 4th, 2014
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. using System;
  2.  
  3. class GCD
  4. {
  5. static void Main()
  6. {
  7. int a = int.Parse(Console.ReadLine());
  8. int b = int.Parse(Console.ReadLine());
  9. if (a < 0)
  10. {
  11. a = a * (-1);
  12. }
  13. if (b < 0)
  14. {
  15. b = b * (-1);
  16. }
  17. while (a != b)
  18. {
  19. if (a > b)
  20. {
  21. a = a - b;
  22. }
  23. else
  24. {
  25. b = b - a;
  26. }
  27. }
  28. Console.WriteLine(a);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement