#include<bits/stdc++.h>
#define sf scanf
#define pf printf
#define LL long long
#define REP(i,MAX) for(int i = 0; i<MAX; i++)
#define MAX INT_MAX
using namespace std;
bool isPrime(int n)
{
if(n == 1) return false;
if(n == 2) return true;
if(n%2==0) return false;
int sqr = sqrt(n);
for (int i = 3; i <= sqr; i+=2)
{
if(n%i == 0){
return false;
}
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
int n;
while(cin >> n && n){
int cnt = 0;
for(int i = n-1; i>=n/2; i--){
if(isPrime(i)){
int diff = n-i;
if(isPrime(diff)){
cnt++;
}
}
}
cout << cnt << '\n';
}
return 0;
}
#define sf scanf
#define pf printf
#define LL long long
#define REP(i,MAX) for(int i = 0; i<MAX; i++)
#define MAX INT_MAX
using namespace std;
bool isPrime(int n)
{
if(n == 1) return false;
if(n == 2) return true;
if(n%2==0) return false;
int sqr = sqrt(n);
for (int i = 3; i <= sqr; i+=2)
{
if(n%i == 0){
return false;
}
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
int n;
while(cin >> n && n){
int cnt = 0;
for(int i = n-1; i>=n/2; i--){
if(isPrime(i)){
int diff = n-i;
if(isPrime(diff)){
cnt++;
}
}
}
cout << cnt << '\n';
}
return 0;
}
No comments:
Post a Comment