Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace CalculateGCD
- {
- class CalculateGCD
- {
- static void Main()
- {
- int a = int.Parse(Console.ReadLine());
- int b = int.Parse(Console.ReadLine());
- List<int> divisors = new List<int>();
- for (int i = 1; i <= b || i <=a; i++)
- {
- if (a % i == 0 && b % i == 0)
- {
- divisors.Add(i);
- }
- }
- foreach (var item in divisors)
- {
- Console.Write(item + " ");
- }
- Console.WriteLine();
- var result = divisors.Max();
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment