Click here to Skip to main content
15,846,727 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Python
import math
for _ in range(int(input())):
    l , b = int(input().split())
    print(math.gcd(l,b))


What I have tried:

sample input ..........................................................................................................
40 30
Posted
Updated 5-May-21 6:39am

1 solution

Because "40 30" is not an integer, so if you input it to start with you will get an error saying that:
Python
for _ in range(int(input())):

If you enter it at your second input, then the split generates a list which isn't convertible directly to an integer either.
Try this:
Python
import math

for _ in range(int(input())):
    l , b = input().split()
    print(math.gcd(int(l),int(b)))
 
Share this answer
 
Comments
Muskan Verma 2021 5-May-21 11:46am    
yaa, it worked.
thanks so much, sir.
OriginalGriff 5-May-21 11:55am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900