Sum of all divisors from 1 to n
Submissions: 1078   Accuracy:

19.71%

  Difficulty: Easy   Marks: 2

Given a positive integer N. The task is to find the value of    \sum_{i=1}^{i=n} F(i)  where function F(i) for number i be defined as sum of all divisors of ‘i‘.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer N.

Output:
For each test case, print the value of function for N in new line.

Constraints:
1<=T<=500
1<=N<=106

Example:
Input:
2
4
5

Output:
15
21

Explanation:

Input: 4
Output: 15
F(1) = 1
F(2) = 1 + 2 = 3
F(3) = 1 + 3 = 4
F(4) = 1 + 2 + 4 = 7
ans = F(1) + F(2) + F(3) + F(4)
    = 1 + 3 + 4 + 7
    = 15

** For More Input/Output Examples Use 'Expected Output' option **

Author: arun03


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.