Create a Python script which will accept two positive integers and will
display the COMMON DIVISORS.
Sample Output:
Positive Integer 1 : 20
Positive Integer 2: 12
COMMON DIVISORS of 20 and 12 are…
1 2 4
Create a Python script which will accept two positive integers and will
display the COMMON DIVISORS.
Sample Output:
Positive Integer 1 : 20
Positive Integer 2: 12
COMMON DIVISORS of 20 and 12 are… 1 2 4
EXPLANATION
the factors of inter 1: 20 are 1 2 4 5 10 20
the factors of integer 2: 12 are 1 2 3 4 6 12
from the above we can see the common divisors are 1 2 4
# python code
num1 = int(input("ENTER FIRST NUMBER : "))
num2 = int(input("ENTER SECOND NUMBER : "))
divisor = 0
print("THE COMMON DIVISORS OF NUMBER ",num1," AND ",num2," ARE -")
for i in range(1,min(num1,num2)+1):
if num1%i == num2%i == 0:
divisor = i
print(divisor)
Comments
Leave a comment