Advertisement
Guest User

ACM884

a guest
Dec 20th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. long long numbers(long long n)
  5. {
  6.     long long i;
  7.     long long count=0;
  8.     for(i=2;i<=sqrt(n);i++)
  9.     {
  10.         while(n%i==0)
  11.         {
  12.             n/=i;
  13.             count++;
  14.         }
  15.     }
  16.     if(n!=1)
  17.     {
  18.         count++;
  19.     }
  20.     return count;
  21. }
  22.  
  23. long long fact(long long n)
  24. {
  25.     if(n<=1)
  26.     {
  27.         return 0;
  28.     }
  29.     else
  30.     {
  31.         return numbers(n)+fact(n-1);
  32.     }
  33. }
  34.  
  35.  
  36. int main()
  37. {
  38.     long long n;
  39.     while(scanf("%lld",&n)!=EOF)
  40.     {
  41.         printf("%lld\n",fact(n));
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement