GCD problem

4

47 votes
Medium-Hard, Mobius Inversion, Number Theory, Mathematics, Greatest common divisor
Problem

For each set of four integers given (i,j,k,l) where 1i<j<k<lN. You are required to compute the following:

Ni=1Nj=i+1Nk=j+1Nl=k+1gcd(i,j,k,l)4

Input format

  • First line: T that denotes the number of test cases
  • Next T lines: A integer N

Output format

Print the answer for each test case Mod109+7 in a new line.

Constraints
1T101N105

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

For First Test case N=4 :
(1,2,3,4) :   gcd(1,2,3,4)4 = 1
Total sum = 1

For Second Test Case N=5 :
(1,2,3,4) :   gcd(1,2,3,4)4 = 1
(1,2,3,5) :   gcd(1,2,3,5)4 = 1
(1,2,4,5) :   gcd(1,2,4,5)4 = 1
(1,3,4,5) :   gcd(1,3,4,5)4 = 1
(2,3,4,5) :   gcd(2,3,4,5)4 = 1
Total sum = 1+1+1+1+1 = 5

Editor Image

?