- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- 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 to print all the numbers divisible by 3 and 5 for a given number

This is a python program to print all the numbers which are divisible by 3 and 5 from a given interger N. There are numerous ways we can write this program except that we need to check if the number is fully divisble by both 3 and 5.

Below is my code to write a python program to print all the numbers divisible by 3 and 5 −

lower = int(input("Enter lower range limit:")) upper = int(input("Enter upper range limit:")) for i in range(lower, upper+1): if((i%3==0) & (i%5==0)): print(i)

## Output

Enter lower range limit:0 Enter upper range limit:99 0 15 30 45 60 75 90

Above we try to print all the numbers between 0 and 99 which are divisble by 3 and 5. Same program can be used to print all the number between 0 and 1000 which are divisible by 3 and 5, we just need to alter our range and our output will be something like,

Enter lower range limit:0 Enter upper range limit:1000 0 15 30 45 60 75 90 105 120 135 150 165 180 195 .... .... 915 930 945 960 975 990

In case we want to write a program which will print all the numbers in a range divisible by a given number not the fixed number like above, i just need to update by program like,

#Incase we want to print all number between a range divided by any given number n = int(input("Enter the number to be divided by:")) for i in range(lower, upper+1): if(i%n==0): print(i)

Below the steps to write above code −

Take the lower and upper limit .i.e. the range from the user.

Take the number to be divided by from the user. In case of our main problem, because we know that numbers(3 and 5), i write the 3 and 5 in the if statement only.

Using a loop with &(and) operator statement(so that it print only those numbers which are divisble by both 3 & 5), prints all the factors which is divisible by the number.

Exit.

- Related Articles
- C# program to print all the numbers divisible by 3 and 5 for a given number
- Python Program to Print all Numbers in a Range Divisible by a Given Number
- Program to print all the numbers divisible by 3 and 5 in C++
- Golang Program to Print all Numbers in a Range Divisible by a Given Number
- Python Program for Efficient program to print all prime factors of a given number
- Python Program to Print all Integers that are not Divisible by Either 2 or 3 and Lie between 1 and 50
- Golang Program to Find the Numbers which are Divisible by 7 and Multiple of 5 in a Given Range
- C Program for efficiently print all prime factors of a given number?
- Divide number into two parts divisible by given numbers in C++ Program
- Python Program to print all distinct uncommon digits present in two given numbers
- Python program to print all even numbers in a range
- Python program to print all odd numbers in a range
- Python Program for Smallest K digit number divisible by X
- Python program to print all Happy numbers between 1 and 100
- Python Program to print all permutations of a given string