Totient sum

5

3 votes
Totient Function, Number theory, Euler's totient function, Mathematics, Number Theory, Math
Problem

Given a positive integer, N

Euler phi function denoted by ϕ(n) counts the number of positive integers up to n that are co-prime to n.
Let us have a function F as:
F(x)=xi=1ij=1ϕ(i)×ϕ(j)


Task
Your task is to calculate the value of F(N). Since the value can be large output it modulo 109+7.

Example

Assumptions

  • N = 4

Approach

  • F(4) = ( ϕ(1).ϕ(1) + ϕ(2).ϕ(1) + ϕ(2).ϕ(2) + ϕ(3).ϕ(1) + ϕ(3).ϕ(2) + ϕ(3).ϕ(3)  + ϕ(4).ϕ(1) + ϕ(4).ϕ(2) + ϕ(4).ϕ(3) + ϕ(4).ϕ(4) ) % ( 109+7 ).
  • F(4)  = 23.

Function description

Complete the solve function provided in the editor. This function takes the following single parameter and returns the value of the function F:

  • N: Represents the value of a number.
     

Input format

Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).

  • The first line contains a single integer T, which denotes the number of test cases. also specifies the number of times you have to run the solve function on a different set of inputs.
  • For each test case:
    • First line contains a single integer denoting the value of N.

Output format

For each test case, print in a new line, a single integer denoting the value of F(N) mod  109+7.
 

Constraints

1T102
1N105
 

Code snippets (also called starter code/boilerplate code) 

This question has code snippets for C, CPP, Java, and Python.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Test Case 1

Given

  • N = 2

Approach

  • F(2)ϕ(1).ϕ(1) + ϕ(2).ϕ(1) + ϕ(2).ϕ(2) = 1 + 1 + 1 = 3.

Test Case 2

Given

  • N = 3

Approach

  • F(3)ϕ(1).ϕ(1) + ϕ(2).ϕ(1) + ϕ(2).ϕ(2) + ϕ(3).ϕ(1) + ϕ(3).ϕ(2) + ϕ(3).ϕ(3) = 1 + 1 + 1 + 2 + 2 + 4 = 11.
Editor Image

?