Advertisement
koksibg

Greatest_Common_Divisor

Nov 10th, 2017
1,164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Greatest_Common_Divisor
  8. {
  9.     class Greatest_Common_Divisor
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int a = int.Parse(Console.ReadLine());
  14.             int b = int.Parse(Console.ReadLine());
  15.             while (b != 0)
  16.             {
  17.                 int oldb = b;
  18.                 b = a % b;
  19.                 a = oldb;
  20.             }
  21.             Console.WriteLine("GCD = {0}", a);
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement