I’m trying to learn computer science by doing some challenges. One is the following.

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

What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

Let’s generalize the problem from $ 1$ to $ n$ .

I thought of a loop between $ n$ and $ n/2$ as everything above $ n/2$ is a multiple of something between $ 1$ and $ n/2$ . At each iteration, the result is the least common multiple of the loop variable and the precedent result (at the beginning the result is 1).

If I am correct, the complexity of this should be $ \mathcal{O}(n/2)$ . Am I right?

Is there any more efficient algorithms to solve this problem? If so witch one and what is their complexity?