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