Write a program to Print all Numbers in a Range Divisible by a Given Number in Python
In this tutorial we are going to learn about writing a program to Print all Numbers in a Range Divisible by a Given Number in Python.
lower=int(input("Enter lower range limit:")) upper=int(input("Enter upper range limit:")) n=int(input("Enter the number to be divided by:")) for i in range(lower,upper+1): if(i%n==0): print(i)
- User must enter the upper range limit and the lower range limit.
- Then the user must enter the number to be divided from the user.
- The value of i ranges from the lower limit to the upper limit and upper +1 is taken because the last number is excluded in range, so to overcome that we add a number which is not necessary.
- Whenever the remainder of the number divided by i is equal to 0, i is printed.