DEV Community

loading...

Discussion on: Project Euler #5 - Finding the Smallest Multiple

Collapse
prabh profile image
Prabhjot Singh Rana

My solution in Python:

result = 1
num = 20
list1 = []
list2 = []
index1= True

for i in range(2,num+1):
    list1.append(i)

while len(list1) > 0:

    a = list1[0]

    for i in list1:
        if index1 == True:
            index1 = False
            result = result * i
            continue
        else:
            if i%a != 0:
                list2.append(i)
            else:
                list2.append(i/a)

    index1 = True

    list1 = list2[:]
    list2 = []

print(result)