← Back to List

17427번: 약수의 합 2 ↗

Solutions

C++14
257 B | 257 chars
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll N,S;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N;
    for(int x=1; x<=N; x++) {
        int c = N/x;
        S += x*c;
    }
    cout << S;
}