Question: Python 3.6- Create a program that takes input from user and finds greatest common divisor(GCD). The program should also give option for user to read
Python 3.6-
Create a program that takes input from user and finds greatest common divisor(GCD). The program should also give option for user to read from "GCD.txt" file , which has a pair of numbers on each line. Then the GCD has to be found for the pair of numbers and the GCD must be written to new txt file called "GCD_result.txt" . Provide indented source code and sceenshot of GCD_results.txt (that found the GCD) to receive full credit. Thanks
Below is the source code that needs correcting:
def gcd(a,b): if b > a: a,b = b, a while b != 0: t = b b = a % t a = t return a def read_file(): with open('GCD.txt', 'w+') as w: fileName = input("What is the file's name? ") myfile = open(fileName) mytxt = myfile.readline() while mytxt: line = mytxt.split() print(gcd(int(line[0]), int(line[1])), file=w) mytxt = myfile.readline() myfile.close() print("Option 1: Read from a file") print("Option 2: Input information onto the keyboard") k = int(input("What would you like to do? ")) if k == 2: print("What is your 2 numbers that you would like to find the Greatest Common Divisor for? ") i = int(input()) j = int(input()) print("The Greatest Common Divisor(GCD) for your input is" , gcd(i, j)) elif k == 1: read_file()
GCD.txt:

GCD.txt X 10 12 12 14 36 48 72 86 8 64 1 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
