Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class GCDEuclidius
- {
- static void Main()
- {
- int firstN = int.Parse(Console.ReadLine());
- int secondN = int.Parse(Console.ReadLine());
- int greatestCD = 0;
- for (int i = 1; i <= Int16.MaxValue; i++)
- {
- if (firstN % i == 0 && secondN % i == 0)
- {
- greatestCD = i;
- }
- if ((i > firstN && firstN > secondN) || (i>secondN && secondN>firstN))
- {
- break;
- }
- }
- Console.WriteLine(greatestCD);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement