Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class CalculateGCD
- {
- static void Main()
- {
- int a, b;
- Console.Write("Enter value of \"a\": ");
- while (!int.TryParse(Console.ReadLine(), out a))
- {
- Console.WriteLine("Invalid input.Try again.");
- Console.Write("Enter value of \"a\": ");
- }
- Console.Write("Enter value of \"b\": ");
- while (!int.TryParse(Console.ReadLine(), out b))
- {
- Console.WriteLine("Invalid input.Try again.");
- Console.Write("Enter value of \"b\": ");
- }
- while (b!=0)
- {
- int temp = b;
- b = a % b;
- a = temp;
- }
- Console.WriteLine(a);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement