Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void Nod()
- {
- int firstNumber = int.Parse(Console.ReadLine());
- int secondNumber = int.Parse(Console.ReadLine());
- int max = Math.Max(firstNumber, secondNumber);
- int min = Math.Min(firstNumber, secondNumber);
- int a = max;
- int b = min;
- int q = (int)Math.Floor((decimal)a / b);
- int r = a - b * q;
- int nod = r;
- while (r != 0)
- {
- a = b;
- b = r;
- q = (int)Math.Floor((decimal)a / b);
- nod = r;
- r = a - b * q;
- }
- Console.WriteLine(nod);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement