Advertisement
EmoRz

Greatest Common Divisor (CGD)

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