#include <bits/stdc++.h>
using namespace std;
vector<int>v;
long long int prime(long long int a)
{
int p,q,f=1;
for(p=2;p<=sqrt(a);p++)
{
if(a%p==0)
{
f=0;
}
}
return f;
}
int main()
{
long long int n,i,j,c,k,y;
while(cin>>n)
{
if(n==4)
{
i=2; //4 is exceptional case
}
else
{
i=3; //3 is prime
}
c=0;
v.clear();
if(n==0)
{
break;
}
while(i<n)
{
j=n-i;
y=1;
for(k=0;k<v.size();k++)
{
if(v[k]==j)
{
y=0;
}
}
if(y==1 && j!=1 && prime(i) && prime(j))
{
c++;
//printf("%lld = %lld + %lld\n",n,i,j);
v.push_back(i);
}
i=i+2;
}
cout<<c<<endl;
}
return 0;
}
0 comments:
Post a Comment