Today we are going to share a Python program to print all the numbers divisible by 3 and 5 for a given number. If you are a python beginner and want to start learning the python programming, then keep your close attention in this tutorial as I am going to share a Python program to print all the numbers divisible by 3 and 5 for a given number.
Copy the below python program and execute it with the help of python compiler.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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) |
0 15 30 45 60 75 90
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.