All problems

Problem 544

Smallest Number Divisible by 1 to N

Easy · 10 pts · Math, Number Theory

Problem

Find the smallest positive integer that is divisible by every integer from 1 to N. This is the least common multiple of 1, 2, ..., N. Build it step by step: lcm(x, i) = x / gcd(x, i) × i. For N = 40 the answer is already around 5 × 10^15, so use 64-bit integers (or big integers) to avoid overflow.

Input

A single integer N.

Output

Print the least common multiple of 1, 2, ..., N.

Constraints

1 <= N <= 40

Example input

10

Example output

2520

Explanation

For N = 10 the answer is 2520 = 2^3 × 3^2 × 5 × 7. It contains the highest power of each prime up to 10 (8, 9, 5 and 7), so every number from 1 to 10 divides it.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Power of Three Next: Pythagorean Triplets Count