I take two numbers from the user and I have to print the numbers between them, which can be divided into 5,000, how to do this in python?
For example, a=12005 and b=28077
the result should be:
15000
20000
25000
I don’t have an idea can you help me with it, please?
>Solution :
You can iterate all numbers with
a = 12005
b = 28077
step = 5000
for num in range(step * (a // step) + step, b, step):
print(num)
The expression step * (a // step) calculates the largest number <= a that is divisible by step. Adding step yields the smallest number > a that is divisible by step. range(step * (a // step) + step, b, step) generate all numbers in the open range (a, b) that are divisible by step.