/* -*- coding: utf-8 -*- * * 3296.cc: No.3296 81-like number - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_P = 100000 + 50; /* typedef */ using ll = long long; using vb = vector; using vi = vector; /* global variables */ vb primes; vi pnums; /* subroutines */ int gen_primes(int maxp) { primes.assign(maxp + 1, true); primes[0] = primes[1] = false; int p; for (p = 2; p * p <= maxp; p++) if (primes[p]) { pnums.push_back(p); for (int q = p * p; q <= maxp; q += p) primes[q] = false; } for (; p <= maxp; p++) if (primes[p]) pnums.push_back(p); return (int)pnums.size(); } ll powi(ll a, int e) { ll p = 1; while (e > 0) { if (e & 1) p *= a; a *= a; e >>= 1; } return p; } /* main */ int main() { gen_primes(MAX_P); ll n; scanf("%lld", &n); ll sum = 0; for (auto p: pnums) { if ((ll)p * p > n) break; int e = 0; for (ll m = n; m >= p; e++, m /= p); sum += (powi(p, e - 1) - 1) / (p - 1) * p * p; } printf("%lld\n", sum); return 0; }