Common Factors (X, Y) and (Y, Z)

Common Factors (X, Y) and (Y, Z): The Program must accept three integers X, Y, Z as the input. The program must find the common factors of X, Y. Then the program must find the common factors of Y and Z. Finally, the program must print all the factors obtained in descending order as the output.

Input:
24 100 80

Output:
20 10 5 4 4 2 2 1 1

X,Y,Z=map(int,input().split())
for Index in range(Y,0,-1):
    if X % Index==0 and Y % Index==0:
        print(Index,end=" ")
    if Y % Index==0 and Z % Index==0:
        print(Index,end=" ")

Leave a Reply

Your email address will not be published. Required fields are marked *

More posts. You may also be interested in.