21-Oct-2022
.
Admin
Hi Dev,
I will explain step by step tutorial Python Program to Print Numbers Divisible by 3. We will use 5. you can see 7. I explained simply about Python program to print all the numbers divisible. Let's see bellow example Python Program to Find Numbers Divisible by Number.
Python Program to Print Numbers Divisible by 3, 5, 7
let's see below simple example with output:
Example 1: Python program to print numbers divisible by 3 and 5 using for loop
# Python program to print numbers divisible by 3 and 5 using for loop
start = int(input("Enter start number:"))
end = int(input("Enter last number:"))
for i in range(start, end+1):
if((i%3==0) & (i%5==0)):
print(i)
Output:
Enter start number: 1
Enter last number: 30
15
30
Example 2: Python program to print numbers divisible by 7 using for loop
# Python program to print numbers divisible by 7 using for loop
start = int(input("Enter start number:"))
end = int(input("Enter last number:"))
for i in range(start, end+1):
if(i%7==0):
print(i)
Output:
Enter start number: 1
Enter last number: 70
7
14
21
28
35
42
49
56
63
70
Example 3: Python program to print first n numbers divisible by 5 using while loop
# Python program to print numbers divisible by 7 using while loop
start = int(input("Enter start number:"))
end = int(input("Enter last number:"))
while(start<=end):
if(start%5==0):
print(start)
start += 1
Output:
Enter start number: 1
Enter last number: 50
5
10
15
20
25
30
35
40
45
50
I hope it can help you...
#Python