• Source
    1. #include<bits/stdc++.h>
    2. #define MAX 1000005
    3.  
    4. using namespace std;
    5.  
    6. int ans[MAX];
    7.  
    8. int give_res(int i)
    9. {
    10. int j,res = 0;
    11.  
    12. while(i%2==0)
    13. {
    14. i/=2;
    15.  
    16. res++;
    17. }
    18.  
    19. for(j=3; j*j<=i; j+=2)
    20. {
    21. while(i%j==0)
    22. {
    23. res++;
    24.  
    25. i/=j;
    26. }
    27. }
    28.  
    29. if(i>1)
    30. res++;
    31.  
    32. return res;
    33. }
    34.  
    35. void cumulative_sum()
    36. {
    37. int i,res;
    38.  
    39. for(i=2; i<=MAX; i++)
    40. {
    41. ans[i] = ans[i-1]+give_res(i);
    42. }
    43. }
    44.  
    45. int main()
    46. {
    47. cumulative_sum();
    48.  
    49. int n;
    50.  
    51. while(scanf("%d",&n)!=EOF)
    52. {
    53. printf("%d\n",ans[n]);
    54. }
    55.  
    56. return 0;
    57. }