1334. Add Up Every Divisor
Print the sum of all positive divisors of n, including 1 and n itself.
6 -> 1 + 2 + 3 + 6 = 12
12 -> 1 + 2 + 3 + 4 + 6 + 12 = 28
97 -> 1 + 97 = 98
This is problem 1318 with addition in place of counting, and it has the same shape and the same trap.
Divisors pair up: if d divides n then so does n / d, and one of the pair is
always at or below the square root. So walk d from 1 while d * d <= n and add
BOTH d and n / d for each hit.
A perfect square has a middle divisor where d and n / d are the same value. It
must be added ONCE. Adding it twice inflates every perfect square, which is why
100 is in the tests: the answer is 217, and double counting the 10 gives 227.
Use a 64-bit accumulator. At n = 10^12 the sum comfortably exceeds what a
32-bit integer holds even when the divisor count is small.
Constraints - `1 ≤ n ≤ 1000000000000`
Input
One line containing the integer n.
Output
Print the sum of all positive divisors of n.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.