Python Program to Find Numbers Divisible by Another Number
Division is a mathematical operation that involves separating a quantity or number into equal parts. It is the inverse operation of multiplication. In division, a number is divided into equal parts, and the result is the number of parts that each part contains.
For example, if we divide 10 by 2, we are dividing 10 into two equal parts, which gives us 5 as the result. In other words, 10 divided by 2 is equal to 5. The symbol used to represent division is /, and it is read as “divided by.”
Division can also be represented using fractions. For example, 10 / 2 can be written as a fraction, which is 10/2. In this case, the numerator (the number on top) represents the quantity being divided, and the denominator (the number on the bottom) represents the number of equal parts into which it is being divided.
It is important to note that division by zero is undefined, meaning it is not a valid mathematical operation. Additionally, when dividing decimals or fractions, it is important to follow specific rules and procedures to ensure accurate results.
Python Code :
The below Python program finds numbers divisible by another number:
# take user input for range and divisor
start = int(input("Enter the starting range: "))
end = int(input("Enter the ending range: "))
divisor = int(input("Enter the divisor: "))
# iterate through the range and check for divisibility
for num in range(start, end+1):
if num % divisor == 0:
print(num, "is divisible by", divisor)
In this program, we first take input from the user for the starting and ending range, as well as the divisor.
We then use a for loop to iterate through the range of numbers, checking for divisibility by the given divisor using the modulus operator (%).
If the remainder is zero, it means the number is divisible by the divisor and we print the number along with a message indicating its divisibility.
For example :
Enter the starting range: 1
Enter the ending range: 10
Enter the divisor: 2
2 is divisible by 2
4 is divisible by 2
6 is divisible by 2
8 is divisible by 2
10 is divisible by 2