- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Python Program for Common Divisors of Two Numbers

In this article, we will learn about the solution to the problem statement given below.

**Problem statement** − We are given two integers, we need to display the common divisors of two numbers

Here we are computing the minimum of the two numbers we take as input. A loop to calculate the divisors by computed by dividing each value from 1 to the minimum computed

Each time the condition is evaluated to be true counter is incremented by one.

Now let’s observe the concept in the implementation below−

## Example

a = 5 b = 45 count = 0 for i in range(1, min(a, b)+1): if a%i==0 and b%i==0: count+=1 print(count)

## Output

2

All the variables are declared in the local scope and their references are seen in the figure above.

## Conclusion

In this article, we have learned about the python program to find the common divisors of two numbers.

- Related Questions & Answers
- C++ Program for Common Divisors of Two Numbers?
- Java Program for Common Divisors of Two Numbers
- C++ Program for the Common Divisors of Two Numbers?
- Program to count number of common divisors of two numbers in Python
- Greatest common divisors in Python
- Check if sum of divisors of two numbers are same in Python
- Print the kth common factor of two numbers
- Python Program for GCD of more than two (or array) numbers
- Count common prime factors of two numbers in C++
- Write a program to calculate the least common multiple of two numbers JavaScript
- Python - Combine two dictionary adding values for common keys
- JavaScript Program for find common elements in two sorted arrays
- Python program to print all the common elements of two lists.
- Position of rightmost common bit in two numbers in C++
- Python program to add two numbers

Advertisements