Advertisement
Guest User

Untitled

a guest
Apr 5th, 2014
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. namespace _17.CalculateGCD
  2. {
  3.     using System;    
  4.     class CalculateGCD
  5.     {
  6.         static void Main()
  7.         {
  8.             int a = int.Parse(Console.ReadLine());
  9.             int b = int.Parse(Console.ReadLine());
  10.  
  11.             int minValue = Math.Min(Math.Abs(a), Math.Abs(b));
  12.  
  13.             for (int i = minValue; i >= 0; i--)
  14.             {
  15.                 if (a % i == 0 && b % i == 0)
  16.                 {
  17.                     Console.WriteLine(i);
  18.                     break;
  19.                 }
  20.             }
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement