Go: package main

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

func search(min, max int, channel chan int) {
	flag := false
	count := 0
	for i := min; i <= max; i++ { //1を除く入力値以下の数字
		for j := 2; j < i; j++ {
			if i%j == 0 {
				flag = true
				break
			}
		}
		if !flag {
			count++
		} else {
			flag = false
		}
	}
	channel <- count
	return
}

func main() {
	count := 0
	channel := make(chan int)
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		for i := 2; i < num; i += 10 {
			if i+10 < num {
				count++
				go search(i, i+10, channel)
			} else {
				count++
				go search(i, num, channel)
			}
		}
		var ans int
		for i := 0; i < count; i++ {
			ans += <-channel
		}

		fmt.Println(ans)
	}
}

C++: #include<stdio.h>

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

int main(void){
	int n,cnt=0;
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		if(p(i)){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

C++: #include <iostream>
#include <list>
#include <algorithm>
 
using namespace std;
 
int main() {
int n;
 
while(!cin.eof()) {
cin >> n;
list<int> search_list(n);
list<int> prime_number;
while(n!=1) {
search_list.push_front(n);
n--;
}
while(!search_list.empty()) {
int m = search_list.front();
prime_number.push_back(m);
search_list.pop_front();
list<int>::iterator it = search_list.begin();
while(it!=search_list.end()) {
if((*it % prime_number.front()) == 0){
it = search_list.erase(it);
continue;
}
it++;
}	
}
cout << prime_number.size()-1 << endl;
}
}

C++: #include<iostream>
#define N 999999
int p[(N+1)/2];int m[N+1];int mk();using namespace std;int main(){int n;p[0]=2;m[1]=0;m[2]=1;mk();while(cin>>n){cout<<m[n]<<'\n';}return 0;}int mk(){int i,j,e=1;for(i=3;i<N;i++){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;
tag:
m[i]=e;}}

C++: #include <bits/stdc++.h>
using namespace std;


bool prime[1000000];
int wei[1000000], sqrt_N = 1000;

int main()
{
  int N, i, j, k;

  for (i = 1; i <= 5; i += 4){
    for (j = i; j <= sqrt_N; j += 6){
      for (k = 1; k <= sqrt_N && (N = 4 * k * k + j * j) <= N; ++k){
        if (N > 1000000) break;
        prime[N] = !prime[N];
      }
      for (k = j + 1; k <= sqrt_N && (N = 3 * k * k - j * j) <= N; k += 2){
        if (N > 1000000) break;
        prime[N] = !prime[N];
      }
    }
  }
  for (i = 2; i <= 4; i += 2){
    for (j = i; j <= sqrt_N; j += 6){
      for (k = 1; k <= sqrt_N && (N = 3 * k * k + j * j) <= N; k += 2){
        if (N > 1000000) break;
        prime[N] = !prime[N];
      }
      for (k = j + 1; k <= sqrt_N && (N = 3 * k * k - j * j) <= N; k += 2){
        if (N > 1000000)break;
        prime[N] = !prime[N];
      }
    }
  }
  for (i = 3; i <= sqrt_N; i += 6){
    for (j = 1; j <= 2; ++j){
      for (k = j; k <= sqrt_N && (N = 4 * k * k + i * i) <= N; k += 3){
        if (N > 1000000) break;
        prime[N] = !prime[N];
      }
    }
  }
  for (i = 5; i <= sqrt_N; ++i){
    if (prime[i]){
      for (j = i * i; j <= N; j += i * i){
        prime[j] = false;
      }
    }
  }
  prime[2] = prime[3] = true;

  for (i = 2; i < 1000000; ++i){
    wei[i] += wei[i - 1];
    if (prime[i]) wei[i]++;
  }

  while (~(scanf("%d", &N))) printf("%d\n", wei[N]);

  return 0;
}

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

bool isPrime(int a){
	int x = std::sqrt((double)a);
	for(;x>1;x-=2)
		if(a%x == 0)
			return false;
	return true;
}

int countPrime(int a){
	int x = a,ans = 1;
	if(x%2==0)
		x--;
	for(; x>1; x-=2)
		if(isPrime(x))
			ans++;
	return ans;
}

int main(){
	int n;
	while(std::cin >> n)
		std::cout << countPrime(n) << std::endl;
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#define REP0(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
using namespace std;
typedef long long ll;
const ll ccc=1000000;
bool prime[ccc+1];
vector<ll> pr;
int main(){
	ll iii,jjj;
	for(iii=0;iii<=ccc;iii++){
		prime[iii]=true;
	}
	prime[0]=false;
	prime[1]=false;
	for(iii=2;iii*iii<=ccc;iii++){
		if(prime[iii]){
			for(jjj=2*iii;jjj<=ccc;jjj+=iii){
				prime[jjj]=false;
			}
		}
	}
	for(iii=2;iii<=ccc;iii++){
		if(prime[iii]){
			pr.push_back(iii);
		}
	}
	int a;
	while(scanf("%d",&a)!=EOF) printf("%d\n",upper_bound(ALL(pr),a)-pr.begin());
	return 0;
}

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

bool primes[1000000];

void Sieve(){
    for(int i= 2; i < 1000000; i++){
        primes[i] = true;
    }
    primes[1] = false;    
    for(int i = 2; i < 1000; i++){
        if(primes[i] == true)
            for(int j=i; j*i < 1000000;j++){
                primes[j*i] = false;
            }
    }     
}
bool IsPrime(int x){
    return primes[x];
}

int main(void){
    Sieve();
    int n, c;
    while(cin >> n){
        c = 0;
        for(int i = 2; i <= n; i++){
        if(IsPrime(i)==true)
            c++;
        }
        cout << c << endl;
    }
    return 0;
}

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

using namespace std;

#define MAX_VALUE 1000000

int get_numprime( int num );

int main(void)
{
	int num;

	while(1)
	{
		cin >> num;
		if( cin.eof() ) break;
		int result = get_numprime( num );
		cout << result << endl;
	}

	return 0;
}

int get_numprime( int num )
{
	int numprime = 1; // 2はカウント済み

	bool erat[MAX_VALUE] = {0};

	for( int i = 0 ; i < num+1 ; i++ )
	{
		erat[i] = true;
	}
	erat[0] = false; erat[1] = false;
	for( int i = 2 ; i <= num ; i++ )
	{
		if( erat[i] )
		{
			for( int j = i*2 ; j <= num ; j+=i )
			{
				erat[j] = false;
			}
		}
	}
	for( int i = 3 ; i <= num ; i+=2 )
	{
		if( erat[i] ) numprime++;
	}

	if( num == 1 ) numprime = 0;

	return numprime;
}

C++: #include <bitset>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    bitset<999999 + 1> b;
    auto t = b;
    t.set();
    t[0] = false;
    t[1] = false;
    int i = 0;
    while (true) {
        bool done = false;
        while (!t[i]) {
            ++i;
            if (i == t.size()) {
                done = true;
                break;
            }
        }
        if (done) {
            break;
        }

        b[i] = true;
        for (int j = i; j < t.size(); j += i) {
            t[j] = false;
        }
    }

    string s;
    while (getline(cin, s)) {
        int n = stoi(s);
        int count = 0;
        for (int j = 1; j <= n; ++j) {
            if (b[j]) {
                ++count;
            }
        }
        cout << count << endl;
    }
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){

    ll n;
    while(cin>>n){
        vector<bool> ip;
        if(ip.size()<n+1){
            ip.resize(n+1,true);
        }
        ip[0]=false;
        ip[1]=false;
        for(int i=2;i<=(n+1)/2;i++){
            for(int j=2;i*j<n+1;j++){
                ip[i*j]=false;
            }
        }
        ll ans=0;
        for(int i=0;i<n+1;i++){
            if(ip[i])ans++;
        }
        
        
        cout<<ans<<endl;
        
        
        
    }





return 0;
}

C++: #include <stdio.h>
#include <math.h>
int check_prime(int a)
{
   int c,b;
   b = (int)sqrt(a);
   for ( c = 2 ; c <=  b; c++ )
   {
      if ( a%c == 0 )
        return 0;
   }
      return 1;
}

int main ()
{
    int  n=0,i=0,prime=0,result=0;

   while( scanf("%d",&n) != EOF)
{
 for(i=2;i<=n;i++)
 {

   result = check_prime(i);

   if ( result == 1 )
     prime = prime +1;
 }
 printf("%d",prime);
 printf("\n");
 prime=0;
}
 return 0;
}