#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
bool judge_zhishu(unsigned num)
{
for (unsigned i = 2; i <= sqrt(num); ++i)
{
if (0 == num%i)
return false;
}
return true;
}
vector<int> zhishu(unsigned n)
{
vector<int> zhishu;
if (n < 2)
{
return zhishu;
}
else
{
if (n == 2)
{
zhishu.push_back(2);
return zhishu;
}
else
{
for (unsigned i = 2; i <= n; ++i)
{
if (judge_zhishu(i))
zhishu.push_back(i);
}
}
}
return zhishu;
}
int main()
{
unsigned n=0;
cin >> n;
vector<int> zhishu_numbers = zhishu(n);
auto beg = zhishu_numbers.cbegin();
auto next = beg + 1;
unsigned count = 0;
for (; next != (zhishu_numbers.cend()); ++beg,++next)
{
if ((*next - *beg) == 2)
++count;
}
cout << count;
system("pause");
return 0;
}
网友评论