Answer to Question #303059 in Python for Loki

Question #303059

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




1
Expert's answer
2022-02-27T07:02:40-0500

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)




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS