Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Euklides
  4. {
  5.  
  6. class Euklides
  7. {
  8. public static int nwd(int x, int y)
  9. {
  10. if (x != y)
  11. {
  12.  
  13. if (x > y)
  14. {
  15. x = x - y;
  16. }
  17. else
  18. {
  19. y = y - x;
  20. }
  21. nwd(x, y);
  22. }
  23.  
  24. return ((x < y) ? x : y);
  25.  
  26. }
  27.  
  28. public static void Main(string[] args)
  29. {
  30.  
  31. int a, b;
  32.  
  33. Console.Write("a = ");
  34. a = int.Parse(Console.ReadLine());
  35. Console.Write("b = ");
  36. b = int.Parse(Console.ReadLine());
  37.  
  38. var eu = new Euklides();
  39. Console.WriteLine("NWD = " + nwd(a, b));
  40. Console.Write("Press any key to continue . . . ");
  41. Console.ReadKey(true);
  42. }
  43.  
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement