X DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Number Game
Easy Accuracy: 32.41% Submissions: 1600 Points: 2

Given a number n the task is to find the minimum number which is divisible by all numbers from 1 to n. Print the answer modulo (109+7).

Example 1:

Input:
n = 3
Output:
6
Explanation:
When n = 3 then the minimum number
that is divisible by all the number
till 3 is 6.

Example 2:

Input:
n = 4
Output:
12
Explanation:
When n = 4 then the minimum number
that is divisible by all the number
till 4 is 12.

You don't need to read input or print anything. Your task is to complete the function numGame() which takes an Integer n as input and returns the answer.

Expected Time Complexity: O(n*log(n))
Expected Auxiliary Space: O(1)

Constraints:
1 <= n <= 105

We are replacing the old Disqus forum with the new Discussions section given below.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

My Submissions:  