Back
Close
  • 302

Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

Statement

 Goal

You have to print the sum of divisors of all the numbers from 1 to n.
It’s superfast when you know the trick but you have to find it.
For example if n=4, lets define d(n) the set of the divisors of n:
* d(1)={1},
* d(2)={1,2},
* d(3)={1,3},
* d(4)={1,2,4}.
And their sum is 1+1+2+1+3+1+2+4=15.
Look carefully at the divisors to find the trick.
Input
A single number n
Output
The sum
Constraints
1⩽n⩽100000
Example
Input
2
Output
4

A higher resolution is required to access the IDE