Python Program to print all the numbers divisible by 3 and 5 for a given number Last Updated : 01 Feb, 2023 Comments Improve Suggest changes Like Article Like Report Given the integer N, the task is to print all the numbers less than N, which are divisible by 3 and 5.Examples : Input : 50Output : 0 15 30 45 Input : 100Output : 0 15 30 45 60 75 90 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 3 and 5. For this divide each number from 0 to N by both 3 and 5 and check their remainder. If remainder is 0 in both cases then simply print that number. Below is the implementation : Python3 # Python program to print all the numbers # divisible by 3 and 5 for a given number # Result function with N def result(N): # iterate from 0 to N for num in range(N): # Short-circuit operator is used if num % 3 == 0 and num % 5 == 0: print(str(num) + " ", end = "") else: pass # Driver code if __name__ == "__main__": # input goes here N = 100 # Calling function result(N) Output0 15 30 45 60 75 90 Time Complexity: O(N)Auxiliary Space: O(1) Alternative Method: This can also be done by checking if the number is divisible by 15, since the LCM of 3 and 5 is 15 and any number divisible by 15 is divisible by 3 and 5 and vice versa also. Python3 # python code to print numbers that # are divisible by 3 and 5 n=50 for i in range(0,n): # lcm of 3 and 5 is 15 if i%15==0: print(i,end=" ") Output0 15 30 45 Time Complexity: O(n)Auxiliary Space: O(1) Alternate Method:Using list comprehension. Python3 # python code to print numbers that # are divisible by 3 and 5 using list comprehension n = 50 result = [i for i in range(n) if i%3==0 and i%5==0] print(result) Output[0, 15, 30, 45] Time Complexity: O(n)Auxiliary Space: O(n) Please refer complete article on Program to print all the numbers divisible by 3 and 5 for a given number for more details! Comment More infoAdvertise with us Next Article Python Program to print all the numbers divisible by 3 and 5 for a given number K kartik Follow Improve Article Tags : Python Python Programs divisibility Practice Tags : python Similar Reads Program to print all the numbers divisible by 3 and 5 for a given number Given the integer N, the task is to print all the numbers less than N, which are divisible by 3 and 5.Examples : Input : 50Output : 0 15 30 45 Input : 100Output : 0 15 30 45 60 75 90 Approach: For example, let's take N = 20 as a limit, then the program should print all numbers less than 20 which are 9 min read Program to print all the numbers divisible by 5 or 7 for a given number Given the integer N, the task is to print all the numbers less than N, which are divisible by 5 or 7. Examples : 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 4 min read Python Program to Find Numbers Divisible by 7 and Multiple of 5 in a Given Range Given a range of numbers, the task is to write a Python program to find numbers divisible by 7 and multiple of 5. Example: Input:Enter minimum 100 Enter maximum 200 Output: 105 is divisible by 7 and 5. 140 is divisible by 7 and 5. 175 is divisible by 7 and 5. Input:Input:Enter minimum 29 Enter maxim 5 min read Python Program to Find Numbers Divisible by Another Number We are given a list of numbers and a number. We have to find all the numbers in the list that are divisible by the given single number. Examples:Input: list=[8, 14, 21, 36, 43], num=3Output: 21, 36, 57Input: list=[2, 17, 25, 31, 48, 55], num=5Output: 25, 55In this article, we will discuss the differ 3 min read Python Program to Print all Integers that Aren't Divisible by Either 2 or 3 We can input a set of integer, and check which integers in this range, beginning with 1 are not divisible by 2 or 3, by checking the remainder of the integer with 2 and 3. Example: Input: 10 Output: Numbers not divisible by 2 and 3 1 5 7 Method 1: We check if the number is not divisible by 2 and 3 u 7 min read Like