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;
- namespace _10.Calculate_GCD
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Please enter the 2 numbers for which you want to find GCD");
- int a = int.Parse(Console.ReadLine());
- int b = int.Parse(Console.ReadLine());
- int remainder1 = Math.Max(a,b);
- int remainder2 = Math.Min(a, b);
- int inter2;
- while (remainder2 !=0)
- {
- inter2 = remainder2;
- remainder2 = remainder1 % remainder2;
- if (remainder2 != 0)
- {
- remainder1 = inter2;
- }
- else
- {
- Console.WriteLine(inter2);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement