Advertisement
krassy_11

GreatestCommonDivisorCGD

Nov 19th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1. using System;
  2.  
  3. class GreatestCommonDivisorCGD
  4. {
  5.     static void Main()
  6.     {
  7.         int a = int.Parse(Console.ReadLine());
  8.         int b = int.Parse(Console.ReadLine());
  9.  
  10.         while (b != 0)
  11.         {
  12.             int oldB = b;
  13.             b = a % b;
  14.             a = oldB;
  15.         }
  16.         Console.WriteLine("GCD = {0}", a);
  17.  
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement