# Name:        Hyrum D. Carroll, Columbus State University
# Date:        December 20, 2018
# Description: Requests two inputs from the user the displays their greatest common divisor.

# Returns the greatest common divisor between a and b.
# Assumes a and b are of type int.
# Code Python's fraction standard library
def gcd(a, b):
    """
    Unless b == 0, the result will have the same sign as b (so that when
    b is divided by it, the result comes out positive).
    """
    while b:
        # assign b to a and the reminder a a divided by b to b
        a, b = b, a%b
    return a

# Requests two numbers from the user and displays their greatest common divisor.
# Repeats until the user doesn't want to continue.
def main():

    # response holds the response to asking the user if they want to continue.
    # It's initialized to 'Y' so that the loop is entered the first time.
    response = 'Y'
    while response[0] == 'y' or response[0] == 'Y':
        # Ask the user for two numbers and echo them back
        num1 = int( input('Please enter a number: '))
        print( f'You entered {num1}')

        num2 = int( input('Please enter another number: '))
        print( f'You entered {num2}')

        # Calculate the greatest common divisor 
        result = gcd( num1, num2 )
        print( f'The greatest common divisor of {num1} and {num2} is {result}')

        # Ask the user if they want to continue
        response = input('Would you like to enter more numbers? (Y/N) ')

    print('Have a nice day!')

# Test if this script is either imported or run by itself
if __name__ == '__main__':
    main()