Advertisement
nikolayneykov

Untitled

Oct 7th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 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.         int gcd = CalculateGCD(a, b);
  10.         Console.WriteLine(gcd);
  11.     }
  12.     static int CalculateGCD(int a, int b)
  13.     {
  14.         if (b == 0)
  15.         {
  16.             return a;
  17.         }
  18.         return CalculateGCD(b, a % b);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement