Floor Sum

4.2

5 votes
Implementation, Basic Programming, Medium, Basics of Implementation, Mathematics
Problem

You are given a number N . You have to find 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: Integer 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

1T100

1N1012

 

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

5/1=5

5/2=2

5/3=5/4=5/5=1

Answer=5+2+1+1+1=10

Editor Image

?