Given n and two positive integers i and j other than 0, print in ascending order the first natural n's that are multiples of i or or both.
Example: For n = 6, i = 2 and j = 3 the output should be: 0,2,3,4,6,8.
n = int(input("Digite n: "))
i = int(input("Digite i: "))
j = int(input("Digite j: "))
lista = []
for k in range(i,i+1):
for l in range(0,n):
print("{}*{} = {}".format(k,l,k*l))
lista.append(k*l)
for k in range(j,j+1):
for l in range(0,n):
print("{}*{} = {}".format(k,l,k*l))
lista.append(k*l)
print(lista)
The above program with n = 6, i = 2 and j = 3 is output:
[0, 2, 4, 6, 8, 10, 0, 3, 6, 9, 12, 15]
For the output to be correct, I would need to sort the above list in ascending order, excluding duplicate values:
[0.2,3,4,6,8,9,10,12,15]
and then get the first 6 values, getting: [0,2,3,4,6,8], which is the expected output.
Any ideas how to improve / correct the above program?