Feb-20-2019, 07:16 PM
I am newbie to Python and tried to write a code to get smallest positive number that is evenly divisible by all of the numbers from 1 to 20. I used the script provided below. It is taking more time to get the result.
How can I tweak this code to get the result sooner.
How can I tweak this code to get the result sooner.
1 2 3 4 5 6 7 8 9 10 11 |
a = 1 while True : n = 0 for y in range ( 1 , 21 ): if a % y = = 0 : n = n + 1 if n = = 20 : print (a) break else : a = a + 1 |