Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class Program
- {
- static void Main()
- {
- int a = int.Parse(Console.ReadLine());
- int b = int.Parse(Console.ReadLine());
- int oldDivisor = 1;
- int newDivisor = 1;
- int smaller = Math.Min(a, b);
- for (int i = oldDivisor; i <= smaller; i++)
- {
- if (a % i == 0 && b % i == 0)
- {
- newDivisor = i;
- }
- if (newDivisor > oldDivisor)
- {
- oldDivisor = newDivisor;
- }
- }
- Console.WriteLine(oldDivisor);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement