(Find numbers divisible by 5 and 6) Write a program that displays, ten numbers per line, all the numbers from 100 to 1,000 that are divisible by 5 and 6. The numbers are separated by exactly one space.
Find numbers divisible by 5 and 6 Program code:
# Function to display numbers from 100 to 1,000 divisible by 5 and 6.
def displayNumbers():
count = 0 # Counter variable to keep track of
#the number of numbers displayed
for num in range(100, 1001):
if num % 5 == 0 and num % 6 == 0:
print(num, end=" ")
count += 1
if count % 10 == 0:
print() # Print a new line after displaying ten numbers
# Display the numbers
print("Numbers from 100 to 1,000 divisible by 5 and 6:")
displayNumbers()
Executed Output:
Numbers from 100 to 1,000 divisible by 5 and 6:
120 150 180 210 240 270 300 330 360 390
420 450 480 510 540 570 600 630 660 690
720 750 780 810 840 870 900 930 960 990