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 <bits/stdc++.h>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

const int inf=100000000;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    int cnt=0;
    for(int i=1; i<=n; i++)
    {
        if(isprime(i)) ++cnt;
    }
    cout<<cnt<<endl;
}

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

// 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){
#ifdef __DEBUG__
		// 入力値のチェック
		if((buf < ((int)(MIN_NUMBER))) || (buf > ((int)(MAX_NUMBER)))){
			cerr << "InputError!!" << endl;
			return -1;
		}
#endif
		// 入力値をリストに追加
		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;
#ifdef __DEBUG__
			}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;
			}
#else
			}
#endif
		}

		// 出力
		cout << n << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
	int n;
	
	while (scanf("%d", &n) != EOF){
		vector<int> prime;
		
		for (int i = 2; i <= n; i++){
			int j;
			for (j = 0; j < prime.size(); j++){
				if (i % prime[j] == 0){
					break;
				}
			}
			if (j == prime.size()){
				prime.push_back(i);
			}
		}
		printf("%d\n", prime.size());
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
static const int MAX = 999999;

bool isPrime[MAX + 1];
int numPrime[MAX + 1];

void calcPrime(){
  for(int i = 0; i <= MAX; i++)
    isPrime[i] = true;
  isPrime[0] = isPrime[1] = false;
  for(int i = 0; i * i <= MAX; i++){
    if(isPrime[i]){
      for(int j = i * 2; j <= MAX; j += i)
        isPrime[j] = false;
    }
  }
  int sum = 0;
  for(int i = 0; i <= MAX; i++){
    if(isPrime[i])
      sum++;
    numPrime[i] = sum;
  }
}

int main(){
  int n;
  calcPrime();
  while(cin >> n){
    cout << numPrime[n] << endl;
  }
}

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

int main() {
    const int numPrimes = 1000000;
	bool primes[numPrimes];
    for (int i = 0; i != numPrimes; ++i) {
        primes[i] = true;
    }

    for (int i = 2; i != sqrt(numPrimes); ++i) {
        for (int j = 2; i * j < numPrimes; ++j) {
            primes[i*j] = false;
        }
    }

    int n;
    while (cin >> n) {
        int count = 0;
        for (int i = 2; i <= n; ++i) {
            if (primes[i]) { ++count; }
        }
        cout << count << endl;
    }
    return 0;
}

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

int main()
{
    int n , m;
    int prime[1000000];
    while(1){
        cin >> n;
        prime[1]=2;
        m=3;
        int i=2;
        while(i<=n){
            int flag=0;
            for(int j=1 ; j<i ; j++){
                if(m % prime[j] == 0){
                    flag++;
                }
            }
            if(flag == 0){
                prime[i]=m;
                i++;
            }
            m++;
        }
        cout << prime[n] <<endl;
    }
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,i,j,k,sum=0,num,SUM=0;
	for(i=0;i<30;i++){
		cin>>n;
		for(j=1;j<=n;j++){
			for(k=j;k>=1;k--){
				num=j/k*k;
				if(num==j)sum++;
			}
			if(sum==2)SUM++;
			sum=0;
		}
		cout<<SUM<<endl;
		SUM=0;
	}
	return 0;
}

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

bool IsPrime(int n) {
    for(int i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
	int n,m;
	m=0;
	while(1){
		m < 30;
		cin >> n;
		if(cin.eof()){
			break;
		}
		m++;
		int count = 0;
		for(int i=2;i<=n;i++){
			if(IsPrime(i)){
				count++;
			}
		}
		cout << count << endl;
	}
	return 0;
}