Create a program to find the GCD (Greatest Common Divisor) of two numbers.
Create a program to find the GCD (Greatest Common Divisor) of two numbers.
189
14-Jun-2023
Aryan Kumar
15-Jun-2023Sure, here is a C# program to find the GCD of two numbers:
C#
This program will first prompt the user to enter two numbers. It will then use Euclid's algorithm to find the GCD of the two numbers. Euclid's algorithm works by repeatedly finding the remainder of the division of one number by the other. The algorithm terminates when the remainder is 0, which means that the two numbers are relatively prime. The GCD is then equal to the last non-zero remainder.
The program will then print the GCD of the two numbers.