Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Finding the number of common divisors of 2 numbers.
- def gcd(a, b):
- if b > 0:
- return gcd(b, a%b)
- else:
- return a
- a, b = map(int, input().split())
- if b > a:
- a, b = b, a
- n = gcd(a, b)
- ans = 0
- sqt = int(n**0.5)
- i = 1
- while i <= sqt:
- if n % i == 0:
- ans += 2
- if i == n//i:
- ans -= 1
- i += 1
- print(ans)
Add Comment
Please, Sign In to add comment