SMALL - Smallest Number


Your task is extremely simple, for a given number N you have to find the smallest number which is divisible by all numbers from 1 to N without leaving any remainder. As the number can be very large print the answer modulo 1000000007.

Input

Input starts with a positive integer T < 501 in a single line, then T lines follow. Each of the T lines contains one positive integer N < 10001.

Output

For every N print the desired number.

Example

Input:
1
5

Output:
60

hide comments
sankalp_7: 2021-07-10 21:45:47

Can also be solved by using sieve concept.

mahilewets: 2017-09-19 21:29:00

Calculate answers for all x, 1<=x<=10000, during run time

PyPy 2.6.0

0.54 sec 120 MB

stranger77: 2017-08-13 07:41:03

no precomputation. Done in 0.01sec

aman224: 2017-03-01 13:11:10

No precomputation needed
AC @0.00s :)

madhavgaba: 2017-01-01 13:41:39

precomputation rocks:D

thug_life: 2016-11-22 17:02:27

@Lakshman would you check whats wrong with my code..its giving correct answers for every test cases I borrowed from spoj toolkit.But still showing wrong answer.Please reply soon.18238934 is the id
Somebody please help!! I think it has something yo do with the input/output thing.Btw I am new to spoj

Last edit: 2016-11-22 17:12:44
Amitayush Thakur: 2016-10-05 12:08:23

Read 1000000007 as 10**8 + 7. Got 1 WA :( then got AC.

Shubham Gupta: 2016-07-08 00:28:10

Superb question.
Keep in mind: LCM(a,b,c) = LCM(a,LCM(b,c))
BUT, LCM(a,b,c)%mod != LCM(a,LCM(b,c)%mod) %mod
With C/C++ it might end up in overflows. Try a different approach!

Piyush Kumar: 2016-06-30 19:51:34

Python like languages are unfair to this question :( . Beautiful question with a peasant solution in Python.

==(Lakshman)=> Here is the medium version http://www.spoj.com/problems/SMALLM/

Re: Thanks :) ! You can also add it to the problem description! :)

Last edit: 2016-07-01 11:27:50
Siddharth Singh: 2016-06-20 17:07:47

Same Logic In Python Gives AC
And C++ WA.
Confused

==(Lakshman)=>why don't you check your both answers of Python and c++?. Wrong answer in c++ is because of overflow.

Last edit: 2016-06-21 05:00:02

Added by:[Lakshman]
Date:2015-01-24
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 JS-MONKEY