Advertisement
dfghjkldfyuhjkfghji

Untitled

Oct 6th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace ExamProblem2
  5. {
  6. class Program
  7. {
  8. public static int NOD(int a, int b)
  9. {
  10. if (a > b)
  11. {
  12. return NOD(a - b, b);
  13. }
  14. if (b > a)
  15. {
  16. return NOD(a, b - a);
  17. }
  18.  
  19. return a;
  20.  
  21.  
  22. }
  23. static void Main(string[] args)
  24. {
  25. string[] inputInfo = Console.ReadLine().Split(' ').ToArray();
  26. int a = int.Parse(inputInfo[0]);
  27. int b = int.Parse(inputInfo[1]);
  28. int c = int.Parse(inputInfo[2]);
  29. int d = int.Parse(inputInfo[3]);
  30.  
  31. int nod1 = NOD(a, b);
  32. int nod2 = NOD(c, d);
  33. Console.WriteLine(NOD(nod1, nod2));
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement