Python Program to Print Numbers Divisible by 3, 5, 7

Python program to print numbers divisible by 7 using for loop
Python program to print numbers divisible by 3 and 5 using for loop
Python program to print first n numbers divisible by 5 using while 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

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

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: 50
7
14
21
28
35
42
49

#python #programming

Python Program to Print Numbers Divisible by 3, 5, 7
255.40 GEEK