Given the integer N, the task is to print all the numbers less than N, which are divisible by 5 or 7.
Input : 20 Output : 5 7 10 14 15 20 Input: 50 Output: 5 7 10 14 15 20 21 25 28 30 35 40 42 45 49 50
Approach: For example, let’s take N = 20 as a limit, then the program should print all numbers less than 20 which are divisible by both 5 or 7. For this divide each number from 0 to N by both 5 and 7 and check their remainder. If the remainder is 0 in both cases then simply print that number.
Below is the implementaion :
5 7 10 14 15 20 21 25 28 30 35 40 42 45 49 50
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Program to print all the numbers divisible by 3 and 5 for a given number
- Python Program to Print all Integers that Aren't Divisible by Either 2 or 3
- Python program to print all Strong numbers in given list
- Python Program to Find Numbers Divisible by 7 and Multiple of 5 in a Given Range
- Python program to print all negative numbers in a range
- Python program to print all Prime numbers in an Interval
- Python program to print all even numbers in a range
- Python program to print all odd numbers in a range
- Python program to print all positive numbers in a range
- Python program to find tuples which have all elements divisible by K from a list of tuples
- Python | Print all string combination from given numbers
- Program to print all distinct elements of a given integer array in Python | Ordered Dictionary
- Python Program to print a number diamond of any given size N in Rangoli Style
- Python program to find all Strong Numbers in given list
- Python program to print odd numbers in a List
- Python program to print even numbers in a list
- Python program to print positive numbers in a list
- Python program to print negative numbers in a list
- Python Program to Print Numbers in an Interval
- Count of numbers in a range that does not contain the digit M and which is divisible by M.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.