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 <iostream>
#include <math.h>
using namespace std;

int main(){
  int a;
  int i, j;
  int past=1, a_sqrt;
  int count;
  bool chk[1000000];

  for(i=1; i<1000000; i++) chk[i]=true;
  while(cin>>a){
    count=0;
    if(past>=a){
      for(i=1; i<=a; i++){
        if(chk[i]) count++;
      }
      printf("%d\n", count);
    }
    else {
      a_sqrt=(int)sqrt((double)a);
      for(i=2; i<=a_sqrt; i++){
        j=past/i; j++;
        chk[j*i]=false;
      }
      past=a;
      for(i=1; i<=a; i++){
        if(chk[i]) count++;
      }
      printf("%d\n", count);
    }
  }

  return 0;
}

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

//??¨??????????????????????????§?´???°??¨?????????
//?´???°??¨??¨?´???????????????£?????????????????§??¨????????????

const int MAX_V = 999999;
int prime[MAX_V + 1]; //?´???°??¨
int sum[MAX_V + 1]; //?´???°?????°???????¨?

int main()
{
	int i, k, v;
	prime[0] = prime[1] = 0;
	for (i = 2; i <= MAX_V; i++)
	{
		prime[i] = 1;
	}
	for (i = 2; i*i <= MAX_V; i++)
	{
		if (prime[i])
		{
			for (k = 2 * i; k <= MAX_V; k += i)
			{
				prime[k] = 0;
			}
		}
	}

	sum[0] = 0;
	for (i = 0; i < MAX_V + 1; i++)
	{
		sum[i+1] = sum[i] + prime[i+1];
	}

	int input;
	while (cin >> input)
	{
		cout << sum[input] << endl;
	}

	return 0;
}

C++: /*
Volume0-0009
*/
//#include <iostream>
#include <stdio.h>
#include <stdlib.h>

#define N 999999
#define M (999999/2)
#define TRUE (char)(0==0)
#define FALSE !TRUE
#define BUFLEN 1024
//using std;

int syserr(char *str)
{
  fputs(str, stderr);
  exit(-1);
}
int main(int argc, char *argv[]){
  int *f;
  if ((f = (int *)malloc(M*sizeof(int)))==NULL)
    syserr((char *)"malloc");

  for (int i=0; i<M; i++){
    f[i] = TRUE;
  }
  for (int i=3; i<N; i+=2) {
    if (f[i/2-1] == TRUE ) {
      for (int j=i+2*i; j<N; j+=2*i){
	f[j/2-1] = FALSE;
      }
    }
  }
  int x = 1;
  for (int i=3; i<N; i+=2) {
    if (f[i/2-1]) {
      x = x + 1;
    }
    f[i/2-1]=x;
  }
  char buf[BUFLEN];
  while (fgets(buf, BUFLEN, stdin) != NULL){
    int n = atoi(buf);
    int m=0;

    if (n==1){
      m = 0;
    } else if (n==2) {
      m = 1;
    } else if (n % 2 == 0) {
      m = f[(n-1)/2 - 1];
    } else {
      m = f[n/2 - 1];
    }

    //    cout << m;
    printf("%d\n", m);
  }

  exit(0);
}

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

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

int main(void){
int unti[100002] = {0};
fill(unti,unti + 100001,0);
for(int n = 2;n < 100001;n++)
{
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 100001;a++)
{
	if((a * n  ) < 100001 ) unti[a * n]++;
}
}
}
int b;
while(cin >> b )
{
int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt << endl;
}

}

C++: // IncludingFiles
#include<iostream>
#include<vector>
#include<cmath>

// Defines
#define     MAX_NUMBER     (999999)
#define     MIN_NUMBER     (1)
// #define     __DEBUG__

// Using Namespace
using namespace std;

// Function
int main(){
	vector <int> PrimeNumbers;
	vector <int> input;
	int buf;
	int sz,maxn;
	int i,root;

	// 入力
	while(cin >> buf){
		// 入力値のチェック
		if((buf <= ((int)(MIN_NUMBER))) || (buf > ((int)(MAX_NUMBER)))){
			cerr << "InputError!!" << endl;
			cerr << "The number has to more than " << ((int)(MIN_NUMBER));
			cerr << " and less than " << (((int)(MAX_NUMBER)) + 1) << "." << endl;
		}else{
			// 問題がなければ入力値をリストに追加
			input.push_back(buf);
		}
	}

	// n の最大値を求めて maxn に代入
	sz = (int)input.size();
	maxn = input[0];
	for(i=1;i<sz;i++){
		if(maxn < input[i]){
			maxn = input[i];
		}
	}

	// 素数2 を 素数表PrimeNumbers に追加
	PrimeNumbers.push_back(2);

	// 3 から maxn までの整数が素数かどうかを調べ、素数であれば 素数表PrimeNumbers に追加
	for(i=3;i<=maxn;i+=2){
		// root に i の平方根を代入
		root = (int)sqrt(i);
		// sz に 素数表PrimeNumbers の大きさを代入
		sz = (int)PrimeNumbers.size();
		// i が 素数表PrimeNumbers に含まれている素数で割り切れないかを確認
		for(buf=0;(buf < sz) && (PrimeNumbers[buf] <= root);buf++){
			if((i % PrimeNumbers[buf]) == 0){						// もし割り切れたら
				goto NotPrime;										// i を素数表に追加しない
			}
		}
		// i は素数である ならば i を 素数表PrimeNumbers に追加
		PrimeNumbers.push_back(i);
		// ここにジャンプする
		NotPrime:;
	}

	// n 以下の素数の個数を計測
	sz = (int)input.size();
	for(i=0;i<sz;i++){
		// a, b および flag の宣言・初期化
		int a = 0,b = (int)PrimeNumbers.size() - 1,m,n;
		bool flag = false;

		// PrimeNumbers の最大値 <= input[i] となっていないかどうかを調べる
		if(PrimeNumbers[b] <= input[i]){
			n = b;
			flag = true;
		}

		// 二分検索
		while (flag == false){
			m = (a + b) / 2;
			if(PrimeNumbers[m] > input[i]){
				b = m;
			}else if((PrimeNumbers[m] <= input[i]) && (PrimeNumbers[m+1] > input[i])){
				n = m;
				flag = true;
			}else if(PrimeNumbers[m] < input[i]){
				a = m;
			}else{
				cerr << "BinarySearchError!!" << endl << endl;
				cerr << "PrimeNumbers[" << m << "] = " << PrimeNumbers[m] << endl;
				cerr << "PrimeNumbers[" << (m + 1) << "] = " << PrimeNumbers[m+1] << endl;
				cerr << "input[" << i << "] = " << input[i] << endl;
				return -1;
			}
		}

		// 出力
		cout << (n + 1) << endl;
	}

	return 0;
}

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

int sosu(int num){
int i;

for(i=2;i<num;i++){

if(num%i==0)return 0;

}
return 1;

}

int main(){
int n,i,count;

while(cin >> n){

for(i=2;i<=n;i++){
if(sosu(i)) count++;
}

cout << count << endl;
i=2;count=0;
}


}

C++: #include <iostream>
using namespace std;
int main(){
	int a[1000001] = {0};
	for(int i = 0; i < 1000001; i++){
		a[i] = 1;
	}
	a[0] = 0;
	a[1] = 0;
	for(int i = 0; i < 1000; i++){
		if(a[i]){
			for(int j = i * 2; j < 1000001; j += i){
				a[j] = 0;
			}
		}
	}

	int n;
	while(cin >> n){
		int k = 0;
		for(int i = 0; i <= n; i++){
			if(a[i]) k++;
		}
		cout << k << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int prime(int);
int main(){
    int a,sum;
    int b[999999];
    b[0]=0;
    for(int i=1;i<999999;i++){
        b[i]=prime(i);
    }
    while ( cin >> a){
        sum =0;
        for (int i=1;i<a;i++){
            sum +=b[i+1];
        }
        cout << sum << endl;
    }
}


int prime(int x){
    if(x==1)
        return 0;
    if(x==2 || x==3 || x==5 || x==7)
        return 1;
    if(x%2==0 || x%3==0)
        return 0;
    for (int i=5;i<=sqrt(x)+1;i+=6){
        if(x%i==0 || x%(i+2)==0)
            return 0;
    }
    return 1;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <math.h>

using namespace std; 

long int a,b,loop,hasil;
long int lo;
long int hi;

bool Prima(unsigned long n) 
{
    if (n % 2 == 0 || n % 3 == 0)
	{
        return false;
    }
 
    for (unsigned short i = 5; i * i <= n; i += 6) 
	{
        if (n % i == 0 || n % (i + 2) == 0) 
		{
            return false;
        }
    }
 
    return true;
}

int main()
{
	while(scanf("%ld",&hi)!= EOF)
	{
	lo=2;
	hasil=1;
		while(lo<=hi)
		{
			if(lo==2||lo==3||lo==5)
			{
				hasil++;
				lo=lo+1; 
			}
			if(lo==4)
			{
				lo++;
			}
			else 
			{
				if(Prima(lo))
				{
					hasil++;
				}
				lo++;
			}
		}
	printf("%d\n",hasil);
	}
	return 0; 
}