Write a Python program that prints all the numbers from 0 to n that are divisible by m. Both n and m are inputs from the user.
Example 1:
Input: n = 10, m = 2
Output: 0, 2, 4, 6, 8, 10
Example 2:
Input: n = 20, m = 5
Output: 0, 5, 10, 15, 20
You can use a for loop to iterate over the range and use the modulo operator to check divisibility.
def print_divisible_numbers(n, m):
for i in range(n+1):
if i % m == 0:
print(i)
print_divisible_numbers(10, 2)
NOTEOwing to browser caching, any code input into the Trinket IDE might carry over across page refreshes or when transitioning between different questions. To commence with a clean slate, either click on the 'Reset Button' found within the IDE's Hamburger icon (☰) menu or resort to using Chrome's Incognito Mode.