Python Program for Common Divisors of Two Numbers Last Updated : 12 Jul, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report Given two integer numbers, the task is to find the count of all common divisors of given numbers? Input : a = 12, b = 24Output: 6Explanation: all common divisors are 1, 2, 3, 4, 6 and 12Input : a = 3, b = 17Output: 1Explanation: all common divisors are 1Input : a = 20, b = 36Output: 3Explanation: all common divisors are 1, 2, 4 Python # Python Program to find # Common Divisors of Two Numbers a = 12 b = 24 n = 0 for i in range(1, min(a, b)+1): if a%i==b%i==0: n+=1 print(n) # Code contributed by Mohit Gupta_OMG Output6 Time Complexity: O(min(a, b)), Where a and b is the given number.Auxiliary Space: O(1) Please refer complete article on Common Divisors of Two Numbers for more details! Comment More infoAdvertise with us Next Article Python Program for Common Divisors of Two Numbers K kartik Follow Improve Article Tags : Python Practice Tags : python Similar Reads Python Program for GCD of more than two (or array) numbers The GCD of three or more numbers equals the product of the prime factors common to all the numbers, but it can also be calculated by repeatedly taking the GCDs of pairs of numbers. gcd(a, b, c) = gcd(a, gcd(b, c)) = gcd(gcd(a, b), c) = gcd(gcd(a, c), b) Python # GCD of more than two (or array) numbe 1 min read Python Program for Check if count of divisors is even or odd Write a Python program for a given number ânâ, the task is to find its total number of divisors that are even or odd. Examples: Input : n = 10 Output: Even Input: n = 100Output: Odd Input: n = 125Output: Even Python Program for Check if count of divisors is even or odd using Naive Approach:A naive a 4 min read Python | sympy.divisor_count() method With the help of sympy.divisor_count() method, we can count the number of divisors of the given integer. Syntax: divisor_count(n, modulus=1) Parameter: n - It denotes an integer. modulus - It is set to 1 by default. If modulus is not 1 then only those that are divisible by modulus are counted. Retur 1 min read Python | sympy.divisors() method With the help of sympy.divisors() method, we can find all the divisors of a given number in sorted order by default. Syntax: divisors(n, generator=False) Parameter: n - It denotes an integer. generator - If generator is True an unordered generator object is returned, otherwise it returns a sorted li 1 min read numpy.floor_divide() in Python numpy.floor_divide(arr1, arr2, /, out = None, where = True, casting = 'same_kind', order = 'K', dtype = None) : Array element from first array is divided by the elements from second array(all happens element-wise). Both arr1 and arr2 must have same shape. It is equivalent to the Python // operator a 3 min read Like