Answer to Question #303084 in Python for Christine

Question #303084

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:43-0500
print('Enter positive Integer 1: ', end='')
n1 = int(input())
print('Enter positive Integer 2: ', end='')
n2 = int(input())
print(f'COMMON DIVISORS of {n1} and {n2} are: ')
if n2 < n1:
    n = n2
else:
    n = n1
for i in range (1, n):
    if (n2 % i == 0) & (n1 % 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