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<vector>
using namespace std;

int main()
{
	vector<int> prime,count;
	int j, k, x, num;
	while (cin >> num){
		prime.push_back(2);
		x = 1;
		k = 1;
		while (prime[k-1] <= num)
		{
			x += 2;
			j = 0;
			while (j < k && x % prime[j] != 0)j++;
			if (j == k)
			{
				prime.push_back(x);
				k++;
			}
		}
		count.push_back(prime.size() - 1);
		prime.clear();
	}
	for (int i = 0; i < count.size(); i++)
	{
		cout << count[i] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<math.h>
using namespace std;
int isPrime(int n) {
	if (n == 2) {
		return 1;
	}
	if ((n <2) || (n % 2 == 0)) {
		return 0;
	}
	int i = 3;
	while (i <= sqrt(n)) {
		if (n % i == 0) {
			return 0;
			
		}
		i += 2;
	}
	return 1;
}
int main()
{
	int x[30];
	int i = 0;
	while (cin >> x[i]) {
		int k = 0;
		for (int j = 0; j < x[i]; j+=2) {
			
			k += isPrime(j+1);
		}
		cout << k+1 << endl;

		i++;
	}

	return 0;
}

C++: #include <cstdio>

using namespace std;

int main() {
    long NUM = 1000000;
	long n = NUM;
	long m = 2;
	bool flag;
	long counter = 0;
	bool primeNum[NUM + 10];

	long i, len = NUM + 10;
	
	for (i = 0; i < len; i++) primeNum[i] = false;
	
    while (m <= n) {
        flag = true;
        len = m / 2;

        for(i = 2; i <= len; i++) {
            if(m % i == 0) {
                flag = false;
                
                break;
            }
        }

        if (flag) primeNum[m] = true;

        m++;
    }
    
    while (scanf("%ld", &n) != EOF) {
        counter = 0;
        
        for (i = 0; i <= n; i++) {
            if (primeNum[i]) counter++;
        }
        
        printf("%ld\n", counter);
    }

    return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  int n;
  int *prime;
  int i,j;
  while(cin >> n){
    //init
    prime = new int[n+1];
    for(i=0; i<=n; i++) prime[i] = 0;

    //素数判定
    for(i=2; i*i<=n; i++){
      if(prime[i] == 0){
	prime[i] = 1; //iは素数
	for(j=2; i*j<=n; j++){//倍数ふるい落とし
	  prime[i*j] = -1;//i*jは素数じゃない
	}
      }
    }
    for(i=i; i<=n; i++){
      if(prime[i] == 0) prime[i] = 1;
    }
    
    //output
    int ans=0;
    for(i=2; i<=n; i++){
      if(prime[i] == 1) {
	ans ++;
	//cout << "prime:" << i << endl;;
      }
    }
    cout << ans << endl;

    delete[] prime;
  }
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    for(;;){
        int n;
        if(!(cin >> n))
            return 0;
        vector<bool> prime;
        makePrimeNumber(n, prime);
        int ret = 0;
        for(int i=0; i<=n; ++i)
            if(prime[i])
                ++ ret;
        cout << ret << endl;
    }
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int prime[100000] = {0};

void makeprime(long long int n)
{
    int k = 1;
    prime[0] = 2;
    for (long long int i = 3; i < n; i++)
    {
        double temp = sqrt(i);
        for (int j = 0; i % prime[j] != 0; j++)
        {
            if (temp < prime[j])
            {
                prime[k++] = i;
                break;
            }
        }
    }
    // rep(i,1000){
    //     cout<<prime[i]<<" ";
    // }
}

int main()
{
    makeprime(999999);
    int n;
    int i;
    while (cin >> n)
    {
        i = 0;
        while (true)
        {
            if (n < prime[i])
            {
                break;
            }
            i++;
        }
        cout << i << endl;
    }
    return 0;
}

C++: #include<cstdio>

int main(){
	int f[1000001] = {};
	int n;

	for(int i = 2; i < 500001; i++){
		f[i * 2] = 1;
	}

	for(int i = 3; i <= 1000; i += 2){
		for(int j = 3; j * i <= 1000000; j += 2){
			f[i * j] = 1;
		}		
	}

	int sum;

	while(scanf("%d", &n) + 1){
		int sum = n - 1;
		while(n){
			if(f[n]){
				sum--;
			}
			n--;
		}
		printf("%d\n", sum);
	}
	return 0;
}

C++: #include<cstdio>

int main(){
	int f[1000001] = {};
	int n;

	for(int i = 2; i < 500001; i++){
		f[i * 2] = 1;
	}

	for(int i = 3; i <= 1000; i += 2){
		for(int j = 3; j * i <= 1000000; j += 2){
			f[i * j] = 1;
		}		
	}

	int sum;

	while(scanf("%d", &n) + 1){
		int sum = n - 1;
		for(int i = 2; i <= n; i++){
			sum -= f[i];
		}
		printf("%d\n", sum);
	}
	return 0;
}

C++: // 2011/06/04 Tazoe

#include <iostream>
using namespace std;

void eratos(bool prime[], int n)
{
	if(n>=1)
		prime[0] = false;
	if(n>=2)
		prime[1] = false;

	for(int i=2; i<n; i++)
		prime[i] = true;

	for(int i=2; i<n; i++){
		if(!prime[i])
			continue;
		for(int j=i+i; j<n; j+=i)
			prime[j] = false;
		if(n<i*i)
			return;
	}
}

int main()
{
	bool prime[1000000];
	eratos(prime, 1000000);

	while(true){
		int n;
		cin >> n;
		if(cin.eof())
			break;

		int cnt = 0;
		for(int i=0; i<=n; i++)
			if(prime[i])
				cnt++;

		cout << cnt << endl;
	}

	return 0;
}

C++: #include <stdio.h>

int main(){
	long sosuu[200000] = { 2 }, i, x, y = 1, z = 0;

	while(scanf("%d", &z)!=EOF){//入力した数以下の素数を表示

		for (i = 3; i < z + 1; i += 2){
			for (x = 0; x < y; x++){
				if (i % sosuu[x] == 0){ break; }
				if (x + 1 == y){ sosuu[y] = i, y++; }
			}
		}
		if (z < 2){ y = 0; }
	printf("%d\n", y);//最後に素数の合計数を表示

	for (i = 1; i < y; i++){
		sosuu[i] = 0;
	}y = 1; z = 0;
	}

	return 0;
}

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

int main(){
    bool is_prime[1000000];

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

    for(int i=2;i*i<1000000;i++){
        if(is_prime[i]){
            for(int j=i*i;j<1000000;j+=i){
                is_prime[j]=false;
            }
        }
    }

    int cnt=0;
    int n_prime[1000000];
    for(int i=0;i<1000000;i++){
        if(is_prime[i]) cnt++;

        n_prime[i]=cnt;
    }

    while(true){
        int n;
        cin>>n;

        if(cin.eof()) break;

        cout<<n_prime[n]<<endl;
    }

    return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int isPrime(int n){
    int i;
    if(n == 2)  return true;
    else if(n < 2 || n % 2 == 0)    return false;
    else{
        i = 3;
        while(i <= sqrt(n)){
            if(n % i == 0)  return false;
            i += 2;
        }
    }
    return true;
}
 
int main(void){
    int n, i, cnt;
    while(cin >> n){
        cnt = 0;
        for(i = 2; i <= n; i++){
            if(isPrime(i))  cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}