Cod sursa(job #1207092)
| Utilizator | Data | 12 iulie 2014 10:51:47 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <fstream>
using namespace std;
ifstream fin("factorial.in");
ofstream fout("factorial.out");
int n,s,p,ciur[100001],i,j,x;
int main()
{fin>>n;
for(i=2;i<=n;i++)
if(ciur[i]==0)
{for(j=i+i;j<=n;j+=i)
ciur[j]=1;
}
p=2;x=2;
while(x<=n)
{while(p<=n)
{s=s+n/p;
p*=x;
}
p=x+1;
while(ciur[p]==1) p++;
x=p;
}
fout<<s<<'\n';
fin.close();
fout.close();
return 0;
}
