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")
Output

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".

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad