In this exercise I need to come up with a way to find the least common multiple (LCM) for the first 20 natural numbers (1-20). So far this is what I got:
if exercise == 34:
lcm = 20
while lcm % 2 != 0 or \
lcm % 3 != 0 or \
lcm % 4 != 0 or \
lcm % 5 != 0 or \
lcm % 6 != 0 or \
lcm % 7 != 0 or \
lcm % 8 != 0 or \
lcm % 9 != 0 or \
lcm % 10 != 0 or \
lcm % 11 != 0 or \
lcm % 12 != 0 or \
lcm % 13 != 0 or \
lcm % 14 != 0 or \
lcm % 15 != 0 or \
lcm % 16 != 0 or \
lcm % 17 != 0 or \
lcm % 18 != 0 or \
lcm % 19 != 0 or \
lcm % 20 != 0:
lcm += 1
print(lcm)
Is there a more efficient, to code this without the need to write a condition for every potential number to be factored in the loop?