Sum of Divisors

AtCoder
IDabc172_d
Time3000ms
Memory256MB
Difficulty
For a positive integer $X$, let $f(X)$ be the number of positive divisors of $X$. Given a positive integer $N$, find $\sum_{K=1}^N K\times f(K)$. ## Constraints * $1 \leq N \leq 10^7$ ## Input Input is given from Standard Input in the following format: $N$ [samples]
Samples
Input #1
4
Output #1
23

We have $f(1)=1$, $f(2)=2$, $f(3)=2$, and $f(4)=3$, so the answer is $1\times 1 + 2\times 2 + 3\times 2 + 4\times 3 =23$.
Input #2
100
Output #2
26879
Input #3
10000000
Output #3
838627288460105

Watch out for overflows.
API Response (JSON)
{
  "problem": {
    "name": "Sum of Divisors",
    "description": {
      "content": "For a positive integer $X$, let $f(X)$ be the number of positive divisors of $X$. Given a positive integer $N$, find $\\sum_{K=1}^N K\\times f(K)$.",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc172_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "For a positive integer $X$, let $f(X)$ be the number of positive divisors of $X$.\nGiven a positive integer $N$, find $\\sum_{K=1}^N K\\times f(K)$.\n\n## Constraints\n\n*   $1 \\leq N \\leq 10^7$\n\n## Input\n\nI...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments