'Why I'm getting time limit exceeded for this code in hackerearth, little shino and common factors problem in python

I'm getting time limit exceeded for this code in hackerearth, 'little shino and common factors' problem in python, can someone help me with the problem


        a,b = map(int,input().split())
        n = 0
        for i in range(1,min(a,b)+1):
            if a%i==b%i==0 :
                n+=1
        print (n)       


Solution 1:[1]

You are getting TLE because the min(a, b) is returning a number greater than 106.
Generally speaking, for a given coding question if there is a time limit of 1 second and your code run for more than 106 times, you will get TLE (time limit exceeded). You can read more about it from here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 enthusiast