Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class GreatestCommonDivisorSecondVersion
- {
- static void Main()
- {
- Console.WriteLine("enter two numbers:");
- int firstValue = int.Parse(Console.ReadLine());
- int secondValue = int.Parse(Console.ReadLine());
- bool check = secondValue % firstValue != 0;
- bool checkTwo = firstValue % secondValue != 0;
- if ((secondValue < firstValue) && (firstValue != 0) && (secondValue != 0))
- {
- while ((firstValue != 0) && (secondValue != 0))
- {
- firstValue %= secondValue;
- if ((firstValue == 0) || (secondValue == 0))
- {
- break;
- }
- secondValue %= firstValue;
- }
- if (firstValue == 0)
- {
- Console.WriteLine("The Greatest Common Divisor of yout numbers is: " + secondValue);
- }
- else if (secondValue == 0)
- {
- Console.WriteLine("The Greatest Common Divisor of yout numbers is: " + firstValue);
- }
- }
- else if ((firstValue < secondValue) && (firstValue != 0) && (secondValue != 0))
- {
- while ((firstValue != 0) && (secondValue != 0))
- {
- secondValue %= firstValue;
- if ((firstValue == 0) || (secondValue == 0))
- {
- break;
- }
- firstValue %= secondValue;
- }
- if (firstValue == 0)
- {
- Console.WriteLine("The Greatest Common Divisor of yout numbers is: " + secondValue);
- }
- else if (secondValue == 0)
- {
- Console.WriteLine("The Greatest Common Divisor of yout numbers is: " + firstValue);
- }
- }
- else
- {
- Console.WriteLine("Wrong Input!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement