Advertisement
g-stoyanov

Exercise8GreatestCommonDivisor

Dec 4th, 2012
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.39 KB | None | 0 0
  1. using System;
  2.  
  3. class Exercise8GreatestCommonDivisor
  4. {
  5.     static int GCD(int a, int b)
  6.     {
  7.         if (b == 0)
  8.         {
  9.             return a;
  10.         }
  11.         else
  12.         {
  13.             return GCD(b, a % b);
  14.         }
  15.     }
  16.     static void Main()
  17.     {
  18.         int a = int.Parse(Console.ReadLine());
  19.         int b = int.Parse(Console.ReadLine());
  20.         Console.WriteLine(GCD(a, b));
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement