DCEPCA03 - Totient Extreme

Given the value of N, you will have to find the value of H. The meaning of H is given in the following code:

H=0;
For (i=1; i<=n; i++) {
    For (j=1; j<=n; j++) {
        H = H + totient(i) * totient(j);
    }
}

Totient or phi function, φ(n) is an arithmetic function that counts the number of positive integers less than or equal to n that are relatively prime to n. That is, if n is a positive integer, then φ(n) is the number of integers k in the range 1 ≤ k ≤ n for which gcd(n, k) = 1

Constraints

0 < T <= 50
0 < N <= 10^4

Input

The first line contains T, the number of test cases. It is followed by T lines each containing a number N .

Output

For each line of input produce one line of output. This line contains the value of H for the corresponding N.

Example

Input:
2
3
10

Output:
16
1024

Added by:dce coders
Date:2012-12-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C CSHARP C++ 4.3.2 CPP C99 HASK JAVA PAS-GPC PAS-FPC PYTHON PYTHON3 PY_NBC
Resource:Own Problem

hide comments
2013-12-29 10:30:38 gourav
awesome brain of problem setter.... ;)
2013-12-29 10:30:38 Ehor Nechiporenko
abdou 00
Totient values for 1, 2, 3 are : 1, 1, 2
Thair pair product is: 1*1+ 1*1+ 1*2 + 1*1 + 1 * 1 + 1 * 2 + 2 * 1 + 2 * 1 + 2 * 2 = 16
2013-12-29 10:30:38 Ehor Nechiporenko
What a nice problem!) Going to resolve it right now)
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.