Advertisement
Guest User

CalculateGCD

a guest
Mar 23rd, 2014
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1. static void Main()
  2.         {
  3.             int a = int.Parse(Console.ReadLine());
  4.             int b = int.Parse(Console.ReadLine());
  5.             int remain = a % b;
  6.             while (remain != 0)
  7.             {
  8.                 a = b;
  9.                 b = remain;
  10.                 remain = a % b;
  11.             }
  12.             Console.WriteLine(b);
  13.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement