Totient sum
Practice
5 (3 votes)
Totient function
Number theory
Euler's totient function
Mathematics
Number theory
Math
Problem
92% Success 749 Attempts 50 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Given a positive integer, N

Euler phi function denoted by \(\phi(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) = \sum_{i=1}^{x}\sum_{j=1}^{i}\phi(i) \times \phi(j)\)


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

Example

Assumptions

  • N = 4

Approach

  • \(F(4)\) = ( \(\phi(1).\phi(1)\) + \(\phi(2).\phi(1)\) + \(\phi(2).\phi(2)\) + \(\phi(3).\phi(1)\) + \(\phi(3).\phi(2)\) + \(\phi(3).\phi(3)\)  + \(\phi(4).\phi(1)\) + \(\phi(4).\phi(2)\) + \(\phi(4).\phi(3)\) + \(\phi(4).\phi(4)\) ) % ( \(10^9 + 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  \(10^9 + 7\).
 

Constraints

\(1 \le T\le10^2\)
\(1 \le N \le 10^5\)
 

Code snippets (also called starter code/boilerplate code) 

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

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
4 votes
Tags:
MathematicsOpenApprovedEasyMathamatics
Points:20
193 votes
Tags:
AlgorithmsApprovedEasyImplementationOpen
Points:50
1 votes
Tags:
Euler's totient functionHardMathNumber Theory