You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
465 B

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n;
bool prime(int x) {
if (x == 2) return 1;
for (int i = 2; i * i <= x; i++)
if (x % i == 0) return 0;
return 1;
}
int main() {
cin >> n;
for (int i = 2; i <= n; i++) {
if (!prime(i)) continue;
LL x = i;
int ans = 0;
while (x <= n) ans += n / x, x *= i;
printf("%d %d\n", i, ans);
}
return 0;
}