Programming Examples

Write a program that takes two integers a and b as input. Print all the numbers between a and b (inclusive) that are divisible by both 3 and 5. If no such numbers exist, display No numbers found


Write a program that takes two integers a and b as input. Print all the numbers between a and b (inclusive) that are divisible by both 3 and 5. If no such numbers exist, display No numbers found

Solution

a = int(input("Enter value of a: "))
b = int(input("Enter value of b: "))
found = False
for i in range(a, b + 1):
    if i % 3 == 0 and i % 5 == 0:
        print(i)
        found = True
if not found:
    print("No numbers found")
▶ RUN

Output/ Explanation:

Takes two integers a and b.

Checks each number between them.

Prints numbers divisible by both 3 and 5 (i.e., divisible by 15).

If none found, prints "No numbers found".

Latest Current Affairs 2026 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad