#K44157. Smallest Multiple Problem
Smallest Multiple Problem
Smallest Multiple Problem
You are given a positive integer n
. Your task is to find the smallest positive integer that is evenly divisible (i.e. divisible without any remainder) by all of the numbers from 1 to n.
This problem requires you to compute the least common multiple (LCM) of all the integers from 1 to n. The answer for a given n
is defined as:
[ S(n) = \text{lcm}(1, 2, \dots, n) \quad ]
For example, if n = 3
, then the multiples you need to consider are 1, 2, and 3, and the smallest number that is divisible by all of these is 6.
Input will be provided via standard input and output must be written to standard output.
inputFormat
The input consists of a single integer n
(1 ≤ n ≤ 40), which represents the upper bound of the range of numbers.
outputFormat
Output a single integer, the smallest multiple that is evenly divisible by all integers from 1 to n
.
1
1