The program should receive three N, A, and B values as input, and should print the multiples of N contained in the interval between A and B. I am doing this, but it is going wrong:
N = int(raw_input())
A = int(raw_input())
B = int(raw_input())
x = range(A, B + 1, N)
try:
for i in range(A, B + 1, N):
if x == [1]:
print 'INEXISTENTE'
else:
print i
except:
if x == [1]:
print 'INEXISTENTE'
If there are no multiples of N in the given range, the program should print "NONEXISTING". The code works for some values, but for others, such as 3, 5, 9 (N, A, and B, respectively), it does not work. Other code tried:
N = int(raw_input())
A = int(raw_input())
B = int(raw_input())
x = range(A, B + 1, N)
for i in range(A, B + 1, N):
if i % N == 0:
print i
It also works for some values and not for others.
Update:
N = int(raw_input())
A = int(raw_input())
B = int(raw_input())
x = range(A, B + 1)
for i in range(A, B + 1):
if i % N == 0:
print i
elif x == []:
print 'INEXISTENTE'
This last code also does not work. If x does not have values, that is, if there are no multiples in the range, the program should print 'NONEXISTENT' if the entries were, for example, 12, 1 and 10, where there are no multiples of 12 between 1 and 10.