Answer to Question #303086 in Python for Cristelle Maddela

Question #303086

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


I need the code to have an output stated above.


1
Expert's answer
2022-02-27T07:02:47-0500
a = 20; b = 12

min = a if a < b else b

for i in range(1, min+1):
    if a%i==0 and b %i==0:
        print(i, end=' ')

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