Summation program
Practice
2.8 (21 votes)
Basic programming
Math
Medium
Problem
41% Success 8778 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a number \(N\). You are required to determine the value of the following function:

long long int solve(N)
{
    ans=0;
    for(i=1;i<=N;i++)
    ans+=(N/i);
    return ans;
}

All divisions are integer divisions(i.e. N/i is actually floor(N/i)).

Input format

  • First line: \(T\) denoting the number of test cases
  • Each of the next \(T\) lines: An integer \(N\)

Output format

For each test case, print the answer in a new line.

Input Constraints

\(1\le T \le 100 \)

\(1 \le N \le 10^{12}\)

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:30
82 votes
Tags:
Medium
Points:30
10 votes
Tags:
Basic ProgrammingC++
Points:30
3 votes
Tags:
Binary search treeCombinatoricsGraphsMedium