How to write all those logical statements in a more efficient way in Python?

  logic, python
i = 20
while (i%2!= 0 or i%3!= 0 or i %  4 != 0 or i %  5 != 0 or
     i %  6 != 0 or i %  7 != 0 or i %  8 != 0 or i %  9 != 0 or
     i % 10 != 0 or i % 11 != 0 or i % 12 != 0 or i % 13 != 0 or
     i % 14 != 0 or i % 15 != 0 or i % 16 != 0 or i % 17 != 0 or
     i % 18 != 0 or i % 19 != 0 or i % 20 != 0):
i+=20
print(i)

I want to find LCM of numbers ranging from 1 to 20. This code in itself is efficient (faster than alternatives), but is there any way that computer can recognize the pattern and make all logical statements accordingly?

Source: Python Questions

LEAVE A COMMENT