#include<bits/stdc++.h>
using namespace std;
#define mx 1000002
long long visit[mx]={0},ans[mx]={0},ar[mx]={0};
long long seive(long long n1)
{
long long i,j,i1;
for(i=3;i*i<=n1;i+=2)
{
if(visit[i]==0)
for(j=i*i;j<=n1;j+=(2*i))
{
visit[j]=1;
}
}
ar[2]=1;
ans[2]=1;
for(i=3;i<=n1;i++)
{
if(i%2==0)
{
ar[i]=ar[i/2]+1;
ans[i]=ans[i-1]+ar[i];
}
else if(visit[i]==0)
{
ar[i]=1;
ans[i]=ans[i-1]+ar[i];
}
else
{
for(i1=3;i1<=sqrt(i);i1+=2)
{
if(i%i1==0)
{
ar[i]=ar[i1]+ar[i/i1];
ans[i]=ans[i-1]+ar[i];
break;
}
}
}
}
}
main()
{
long long n;
seive(1000000);
while(cin>>n)
{
cout<<ans[n]<<endl;
}
}
using namespace std;
#define mx 1000002
long long visit[mx]={0},ans[mx]={0},ar[mx]={0};
long long seive(long long n1)
{
long long i,j,i1;
for(i=3;i*i<=n1;i+=2)
{
if(visit[i]==0)
for(j=i*i;j<=n1;j+=(2*i))
{
visit[j]=1;
}
}
ar[2]=1;
ans[2]=1;
for(i=3;i<=n1;i++)
{
if(i%2==0)
{
ar[i]=ar[i/2]+1;
ans[i]=ans[i-1]+ar[i];
}
else if(visit[i]==0)
{
ar[i]=1;
ans[i]=ans[i-1]+ar[i];
}
else
{
for(i1=3;i1<=sqrt(i);i1+=2)
{
if(i%i1==0)
{
ar[i]=ar[i1]+ar[i/i1];
ans[i]=ans[i-1]+ar[i];
break;
}
}
}
}
}
main()
{
long long n;
seive(1000000);
while(cin>>n)
{
cout<<ans[n]<<endl;
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন