Advertisement
kisyova

CalculateGCD

Apr 5th, 2014
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2.  
  3.     class CalcilateGCD
  4.     {
  5.         static void Main()
  6.         {
  7.             Console.Write("Enter your first integer number: ");
  8.             int first = int.Parse(Console.ReadLine());
  9.             Console.Write("Enter your second integer number: ");
  10.             int second = int.Parse(Console.ReadLine());
  11.  
  12.             while (first != 0 && second != 0)
  13.             {
  14.                 if (first > second)
  15.                 {
  16.                     first -= second;
  17.                 }
  18.                 else
  19.                 {
  20.                     second -= first;
  21.                 }
  22.             }
  23.  
  24.             Console.WriteLine(Math.Max(first,second));
  25.            
  26.         }
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement