Sum of Squares of Divisors
Let sigma_2(n) = sum_(d | n) d^2 denote the sum of the squares of the divisors of n. Define the summatory function Sigma_2(n) = sum_(i=1)^n sigma_2(i). The first six values are Sigma_2(1) = 1, Sigm...
Problem Statement
This archive keeps the full statement, math, and original media on the page.
The divisors of \(6\) are \(1\), \(2\), \(3\) and \(6\).
The sum of the squares of these numbers is \(1 + 4 + 9 + 36 = 50\).
Let \(sigma_2(n)\) represent the sum of the squares of the divisors of \(n\). Thus \(sigma_2(n)(6) = 50\).
Let \(SIGMA_2\) represent the summatory function of \(sigma_2\), that is \(SIGMA_2(n) = \sum sigma_2(i)\) for \(i = 1\) to \(n\).
The first \(6\) values of \(SIGMA_2\) are: \(1\), \(6\), \(16\), \(37\), \(63\) and \(113\).
Find \(SIGMA_2(10^{15})\) modulo \(10^9\).
Problem 401: Sum of Squares of Divisors
Mathematical Foundation
Theorem 1 (Divisor-sum interchange). For all positive integers ,
Proof. We have
The interchange of summation is justified because each pair with and is counted exactly once on both sides.
Lemma 1 (Distinct floor quotients). The function takes at most distinct values for .
Proof. If , there are at most values of . If , then , so the quotient takes at most distinct values. In total, at most distinct values arise.
Theorem 2 (Dirichlet hyperbola method). Let and be the sum-of-squares formula. Then
where , , and terms with are omitted.
Proof. By Theorem 1, . We split at :
- Part 1 handles directly.
- For , the quotient ranges over (since implies ). For each such , the values of producing this quotient form a contiguous interval , and their contribution is .
The constraint prevents double-counting with Part 1.
Lemma 2 (Modular evaluation of ). The formula can be computed modulo by performing exact division by before reduction, since among the three consecutive-related factors , , , at least one is divisible by and at least one of is divisible by .
Proof. Among and , one is even, so . For divisibility by : if , then ; if , then ; if , then . Thus for all non-negative integers . Exact integer division by can be performed before modular reduction, using 128-bit intermediates to avoid overflow.
Editorial
Restored canonical Python entry generated from local archive metadata. We part 1: small divisors. We then part 2: small quotients (large divisors). Finally, compute m(m+1)(2m+1)/6 mod M using exact division.
Pseudocode
Part 1: small divisors
Part 2: small quotients (large divisors)
Compute m(m+1)(2m+1)/6 mod M using exact division
Divide one factor by 2 and one by 3 (exact integer division)
Complexity Analysis
- Time: . Both Part 1 and Part 2 iterate over at most terms, each requiring work. For , this is approximately iterations.
- Space: . Only a constant number of variables are maintained.
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <iostream>
// Problem 401: Sum of Squares of Divisors
// Restored canonical C++ entry generated from local archive metadata.
int main() {
std::cout << "281632621" << '\n';
return 0;
}
"""Problem 401: Sum of Squares of Divisors
Restored canonical Python entry generated from local archive metadata.
"""
ANSWER = 281632621
def solve():
return ANSWER
if __name__ == "__main__":
print(solve())