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>
#include <math.h>
#include <stdlib.h>
#include <iostream>

#define N 1000000L
bool num[N];

void furui(void){
  long int i;
  int divide;
  int rt = 1000;
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0L] = false;
  num[1L] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = (long int) divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(void){
  int c, i, j;
  long int k;
  char buf[7];
  long int n;
  long int count;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0;(c = getchar()) != EOF ;i++){

      if(c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    if(c == EOF) break;
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == true) count++;
    }
    std::cout << count << std::endl;
  }
  return 0;
}

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

int CountPrime(int n){
	
	if ((n == 0) || (n == 1)){
		return 0;
	}else{
		std::vector<bool> data(n - 1, 1);
		int count = 0;

		for (int i = 2; i <= n; i++){
			if (data[i - 2] == 1){
				for (int j = i * 2; j <= n; j += i){
					data[j - 2] = 0;
				}
			}
		}
		for (int i = 0; i < n - 1; i++){
			if (data[i] == 1){
				count++;
			}
		}

		return count;

	}
}


int main(){
	int n;

	while (std::cin >> n){
		std::cout << CountPrime(n) << "\n";
	}

	return 0;
}

C++: #include<stdio.h>

int main()
{
	int n,m;
	while(scanf("%d",&n) !=EOF)
	{
		m=0;
		for(int x=2;x<=n;x++)
		{
			for(int y=x-1;y;y--)
			{
				if(y==1)
				{
					m++;
				}
				else if(x%y==0)
				{
					break;
				}				
			}
		}
		printf("%d\n",m);
	}
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <iterator>

#include <cmath>

int main(void){
	using namespace std;

	map<int,int> input_dic;
	list<int> input;
	int k;

	while(cin >> k){
		input.push_back(k);
		input_dic[k] = 0;
	}

	int k_max = ( input_dic.rbegin() )->first;
	vector<bool> sieve(k_max, false);

	int sq_k_max = sqrt(k_max);
	for (int x=1; x<=sq_k_max; ++x) {
		for (int y=1; y<=sq_k_max; ++y) {
			int n = 4*x*x + y*y;
			if ( n<=k_max && (n%12==1 || n%12==5) ){
				sieve[n] = !sieve[n];
			}
			n = 3*x*x + y*y;
			if ( n<=k_max && n%12==7 ){
				sieve[n] = !sieve[n];
			}
			n = 3*x*x - y*y;
			if ( x>y && n<=k_max && n%12==11 ){
				sieve[n] = !sieve[n];
			}
		}
	}
	for (int n=5; n<=sq_k_max; ++n){
		if (sieve[n]){
			for (int k=n*n; k<=k_max; k+=n*n){
				sieve[k] = false;
			}
		}
	}
	sieve[2] = sieve[3] = true;

	int primeCount = 0;
	auto sieveItr = sieve.begin();
	for( auto itr=input_dic.begin(); itr!=input_dic.end(); itr++){
		for( ; distance(sieve.begin(),sieveItr) <= itr->first; sieveItr++){
			if( *sieveItr ){
				primeCount++;
			}
		}
		itr->second = primeCount;
	}

	for(auto itr=input.begin(); itr!=input.end(); itr++){
		cout << input_dic[*itr] << endl;
	}

}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>

#define INF 999999
using namespace std;

int main()
{
	int n;
	
	while (cin >> n)
	{
		int ans = 0,rootn;

		int a[INF] = {0};
		
		rootn = sqrt(n)+1;
	
		for (int i = 2; i <= rootn; i++)
		{
			if (a[i]==0)
			{
				for (int j = i+1; j <= INF; j++)
				{
					if (a[j] == 0 && j%i == 0)
					{
						a[j] = 1;
					}
				}
			}
		}
		cout << "a" << endl;
		for (int i = 2; i <= n; i++)
		{
			if (a[i]==0)
				++ans;
		}
		cout << ans << endl;
	}
			
	return 0;
}

C++: #include<stdio.h> int prime[1000000]; int main(){ prime[0]=-1; prime[1]=-1; for(int i=2;i<1000000;i++){ if(prime[i]==0){ prime[i]=1; for(int j=i*2;j<1000000;j+=i)prime[j]=-1; } } int now; while(~scanf("%d",&now)){ int ans=0; for(int i=1;i<now+1;i++)if(prime[i]==1)ans++; printf("%d\n",ans); } }

C++: /*
P135
AOJ 0009 Prime Number
Difficult: 2
*/

#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <functional>
#include <string.h>
#include <cmath>

using namespace std;

const int MAXN = 999999;
int prime[MAXN + 1], pn;
int mindiv[MAXN + 1];

void GetPrime(int n)
{   //determin each num (that <= n) is prime or not.
    //and get primes into an array with pn elements
    //mindiv[i] == i means it is a prime
    fill(mindiv, mindiv+n+1, 0);
    pn = 0;
    for(int i=2; i<=n; ++i){
        if(mindiv[i] == 0) mindiv[i] = i, prime[pn++] = i;
        for(int p=0; p<pn && i*(long long)prime[p] <= n; ++p){
            mindiv[prime[p]*i] = prime[p];
            if(prime[p] == mindiv[i]) break;
        }
    }
}


int main()
{
    GetPrime(MAXN);
    int n;
    while(scanf("%d", &n) !=EOF){
        int x = upper_bound(prime, prime + pn, n) - prime;
        printf("%d\n", x);
    }

}

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[100100];

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

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

using namespace std;
bool IsPrime[1000000];
vector<int> Prime;

void calc()
{
	for(int i = 0; i < 1000000; ++i)
	{
		IsPrime[i] = true;
	}
	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()
{
	calc();
	int n;
	while(cin >> n)
	{
		int count = 0;
		int a = Prime.size() - 1;
		while(Prime[count] <= n)
		{
			if(count >= a)
			{
				break;
			}
			count++;
		}
		cout << count << endl;
	}
}

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

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN = 1000000+10;
const int maxn=100000+5;
int prime[maxn];
bool p[MAXN];
int cnt=0;
void getPrime()
{
    memset(p,true,sizeof(p));
    p[0]=p[1]=false;
    for(int i=2;i<=MAXN;i++)
       if(p[i]) {
       	prime[cnt++]=i;
       	for(int j=i*i;j<=MAXN;j+=i)
       	    p[j]=false;
	   }
}
int main()
{
	getPrime();
	/*int k=lower_bound(prime,prime+cnt,999999)-prime;
	for(int i=k;i>=0;i--)
	   if(prime[i]<999999) {
	   	printf("%d\n",i+1);
	   	break;
	   }*/
	for(int i=0;i<cnt;i++)
	   cout<<prime[i]<<" ";
	int n;
	while(scanf("%d",&n)==1){
		int k=lower_bound(prime,prime+cnt,n)-prime;
		if(prime[k]==n) k++;
		printf("%d\n",k);
	}
	return 0;
}

C++: #include <cstdio>

int main(){
	int n;
	bool c[1000000]={true};
	int t[1000000];t[0] = 0;
	for(int i = 2;i < 1000000;i++){
		for(int j = i;i*j < 1000000;j++){
			c[i*j-1] = true;
		}
	}
	for(int i = 1;i < 1000000;i++){
		if(c[i])t[i]=t[i-1];
		else t[i] = t[i-1]+1;
	}
	while(scanf("%d", &n)){
		printf("%d\n", t[n-1]);
	}
	return 0;
}