nikolayneykov

Untitled

Oct 7th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1. using System;
  2.  
  3. class GreatestCommonDivisor
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int a = int.Parse(Console.ReadLine());
  8.         int b = int.Parse(Console.ReadLine());
  9.         while (a != b)
  10.         {
  11.             if (a > b)
  12.             {
  13.                 a = a - b;
  14.             }
  15.             else
  16.             {
  17.                 b= b - a;
  18.             }
  19.         }
  20.         Console.WriteLine(b);
  21.     }
  22. }
Add Comment
Please, Sign In to add comment