Avatar ·

More efficient implementation of a brute-force algorithm to find the smallest positive number that is divisible by all numbers from 1 to 20

📁 Advanced Python Topics

There is a problem:

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

Find the smallest positive number that is divisible by all numbers from 1 to 20?

I solved this problem by writing a poorly optimized brute-force algorithm.

calculate = Truemax_number = 20min_number = 1current_divisible = 2520count = 0while calculate:   for i in range(2, max_number + 1):       if current_div