Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		flag := false
		count := 0

		for i := 2; i <= num; i++ { //1を除く入力値以下の数字
			for j := 2; j < i-1; j++ {
				if i%j == 0 && j != 1 {
					flag = true
					//fmt.Println(i, "/", j)
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

C++: #include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <vector>

std::vector<std::size_t> prime_table = {2};

void make_prime_table(const std::size_t n)
{
    const std::size_t found_last_prime = prime_table.back();
    if(found_last_prime < n)
    {
        std::list<std::size_t> undefined_table;

        for(std::size_t i = found_last_prime + 1; i <= n; ++i)
        {
            undefined_table.push_back(i);
        }

        const std::size_t sn = std::sqrt(n);
        for(std::size_t p = 0; ; ++p)
        {
            for(auto u = undefined_table.begin(); u != undefined_table.end();)
            {
                if(0 == *u % prime_table[p])
                {
                    u = undefined_table.erase(u);
                }
                else
                {
                    ++u;
                }
            }
            if(undefined_table.empty())
            {
                break;
            }
            if(found_last_prime <= prime_table[p])
            {
                prime_table.push_back(undefined_table.front());
                undefined_table.pop_front();
            }
            if(prime_table.back() <= sn)
            {
                break;
            }
        }
        prime_table.insert(prime_table.end(), undefined_table.begin(), undefined_table.end());
    }
}

std::vector<size_t> prime_acc = {0};

std::size_t prime_size(const std::size_t limit)
{
    if(prime_acc.size() <= limit)
    {
        make_prime_table(limit);
        auto it = prime_table.begin();
        while(prime_acc.size() <= limit)
        {
            it = std::lower_bound(it, prime_table.end(), prime_acc.size());
            if(it != prime_table.end())
            {
                prime_acc.insert(prime_acc.end(), *it - prime_acc.size(), prime_acc.back());
                prime_acc.push_back(prime_acc.back() + 1);
            }
            else
            {
                prime_acc.insert(prime_acc.end(), limit - prime_acc.size() + 1, prime_acc.back());
            }
        }
    }
    return prime_acc[limit];
}

int main()
{
    std::size_t n;

    while(std::cin >> n, !std::cin.eof())
    {
        std::cout << prime_size(n) << std::endl;
    }
}

C++: #include <iostream>
#include <cmath>

using namespace std;
int main()
{
    bool a[1000000];
    for (int i = 0; i < 1000000; i++) {
        a[i] = true;
    }
    for (int i = 2; i <= sqrt(1000000); i++) {
        if (a[i]){
            for (int j = i; i*j < 1000000; j++) {
                a[i*j] = false;
            }
        }
    }
    
    
    int n;
    while (cin >> n) {
        int cnt = 0;
        for (int i = 2; i <= n; i++) {
            if (a[i]){
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int a[1000000];
int sum[1000000];
int n;
int main(){
 for (int i=2;i<1000000;i++){
  if (!a[i])
   for (int j=i*2;j<1000000;j+=i)
    a[j]=1;
 }
 for (int i=2;i<1000000;i++) sum[i]=sum[i-1]+(a[i]==0?1:0);
 while (cin>>n)
  cout<<sum[n]<<endl;
 return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
  bool p[1000000];
  int num[1000000];
  int c,n;

  for(int i=0;i<1000000;i+=2)p[i] = false;
  for(int i=1;i<1000000;i+=2)p[i] = true;
  p[1] = false;
  p[2] = true;

  c = 3;
  while(c < 1000){
    for(int i=3*c;i<1000000;i+=2*c)p[i] = false;
    do{c+=2;}while(!p[c]);
  }

  c = 0;
  for(int i=0;i<1000000;i++){
    if(p[i])c++;
    num[i] = c;
  }

  while(cin >> n)cout << num[n];
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

bool prime(int p){
	if ((p==0)||(p==1)){return false;}
	else if(p==2){return true;}
	else{
		for(int i=2; i*i<=p; i++){
			if(p%i == 0){return false;}
		}
	}
	return true;
}

int main()
{
	int n;

	while(cin >> n){
		int count = 0;
		for(int i=0; i<n+1; i++){
			if(prime(i)){count++;}
		}

		cout << count << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

bool prime(int p){
	if ((p==0)||(p==1)){return false;}
	else if(p==2){return true;}
	else{
		for(int i=2; i*i<=p; i++){
			if(p%i == 0){return false;}
		}
	}
	return true;
}

int main()
{
	int n;

	while(cin >> n){
		int count = 0;
		if(n>2){count++;}
		for(int i=1; i<n+1; i=i+2){
			if(prime(i)){count++;}
		}

		cout << count << endl;
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

bool Is_Prime(int n){
  if(n==1) return false;
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      return false;
    }
  }
  return true;
}
int p[100006];

signed main(){
  loop(i,2,100001){
    if(Is_Prime(i))p[i]=1;
  }
  rep(i,100001)p[i+1]+=p[i];
  int n;
  while(cin>>n){
    cout<<p[n]<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>

using namespace std;

vector<int> Prime;
void PrimeCalc(int n)
{
	bool IsPrime[1000000];
	for(int i = 0; i < 1000000; ++i)
	{
		IsPrime[i] = true;
	}
	IsPrime[0] = IsPrime[1] = false;
	for(int i = 2; i < 1000000; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 1000000; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	int n;
	cin >> n;
	PrimeCalc(n);
	int ans = 0;
	int pos = 0;
	for(int i = 0; i < Prime.size(); ++i)
	{
		if(Prime[i] <= n)
		{
			++ans;
		}
		else
		{
			break;
		}
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
using namespace std;
#define MAX 10000
bool prime[MAX];
int main(void){ 

  fill(prime,prime+MAX,true);
  prime[0] = prime[1] = false;
  for(int i = 2 ; MAX > i * i ; i ++){
    if(prime[i]){
      for(int j = i + i ; MAX > j * j ; j += i){
	prime[j] = false;
      }
    }
  } 
  int n;
  while(cin>>n,n){
    if(n%2)cout<<"0"<<endl;
    else{
      int cnt = 0,sum = 0;
      for(int i = 0 ; i <= n/2 ; i ++){
	for(int j = i ; j < n ; j ++){
	  if(prime[i] && prime[j]){
	    if(i+j==n)cnt++;
	  } 
	}
      } 
      cout<<cnt<<endl;
    }
  }
}