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>
#include<cmath>
using namespace std;

int main(){
    long maxy = (long)sqrt(1000000);
    int prime[maxy];
    //ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
    
    for(int i = 0; i < maxy; i++){
        prime[i] = 1;
    }
    prime[0] = prime[1] = 0;
    for(int i = 2; i <= (int)maxy; i++){
        if(prime[i] == 1){
            for(int j=i*2; j <= (int)maxy; j+=i){
                prime[j] = 0;
            }        
        }
    }
    int n;
    while(cin >> n){
        int ans = 0;
        for(int i=0; (i <= maxy && i <= n); i++){
            if(prime[i] == 1){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
int main(int argc, const char * argv[])
{

    // insert code here...
    
    while(true)
    {
        int n;
        std::cin >> n;
        if(std::cin.eof())break;
        
        int count = 0;
        std:
        for(int i=2;i<n;i++)
        {
            bool flag = true;
            for(int j=2;j<i/j+1;j++)
            {
                if(i%j==0)
                {
                    flag=false;
                    break;#include <iostream>
int main(int argc, const char * argv[])
{

    // insert code here...
    
    while(true)
    {
        int n;
        std::cin >> n;
        if(std::cin.eof())break;
        
        int count = 0;
        std:
        for(int i=2;i<n;i++)
        {
            bool flag = true;
            for(int j=2;j<i/j+1;j++)
            {
                if(i%j==0)
                {
                    flag=false;
                    break;
                }
            }
            if(flag)
            {
                count++;
            }
        }
        
        std::cout << count <<"\n";
        
    }
    
    return 0;
}


                }
            }
            if(flag)
            {
                count++;
            }
        }
        
        std::cout << count <<"\n";
        
    }
    
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cctype>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
const double PI = 3.141592653589793238462643383279502884L;
const int LARGE_INT = 1000000007;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i,a,cont,next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i,a,b,s) repfn(i,a,i<b,i+s)
#define repab(i,a,b) repby(i,a,b,1)
#define rep(i,b) repab(i,0,b)
#define pb push_back
#define sz(c) int((c).size())

int check(vector<bool> &v, int from, int to)
{
  int i;
  for (i = from + 1; i*i <= to && i*i < sz(v); i++) {
    if (v[i]) {
      for (int j = 2; i*j < sz(v); j++) {
        v[i*j] = false;
      }
    }
  }
  return i - 1;
}

int count(vector<bool> &v, int to)
{
  int res = 0;
  repab (i, 2, to+1) {
    if (i >= sz(v))
      break;
    if (v[i])
      res++;
  }
  return res;
}

int main(int argc, char **argv)
{
  const int prime_max=1000000;
  vector<bool> v(prime_max, true);
  int done;

  int n;
  done = 1;
  while (cin >> n) {
    done = check(v, done, n);
    cout << count(v, n) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;
int sieve(int n);
int prime[1000000];
bool is_prime[1000000];

int main()
{
	while(true) {
		int n;
		cin >> n;
		cout << sieve(n) << endl;
	}
}

int sieve(int n) {
	int p = 0;
	for (int i = 0; i <= n; i++) {
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
	return p;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
vector<bool> GetPrimeTable(int n)
{
	vector<bool> IsPrimeNumber(n+1, true);
	for(int i = 2; i <= n; i++){
		while(IsPrimeNumber[i] == false){
			i++;
		}
		for(int j = 2; i*j <= n; j++){
			IsPrimeNumber[i*j] = false;
		}
	}
	return IsPrimeNumber;
}

int GetPrimeCount(vector<bool>& IsPrimeNumber, int n)
{
	int Count = 0;
	for(int i = 2; i <= n; i++){
		if(IsPrimeNumber[i] == true){
			Count++;
		}
	}
	return Count;
}

int main()
{
	vector<int> Input;
	while(true){
		int Nubmer;
		cin >> Nubmer;
		if(cin.eof() == true) break;
		Input.push_back(Nubmer);
	}
	int MaxNumber = *std::max_element(Input.begin(), Input.end());
	vector<bool> IsPrimeNumber = GetPrimeTable(MaxNumber);
	for(int i = 0; i < Input.size(); i++){
		cout << GetPrimeCount(IsPrimeNumber, Input[i]) << endl;
	}
	return 0;
}

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

typedef int TInt;
typedef std::vector<TInt> TList;
bool IsPrime(TInt Value, const TList& Prime)
{
    TInt Max = std::sqrt(Value);
    for(TList::const_iterator It = Prime.begin();
        It != Prime.end() && *It <= Max;
        ++It)
    {
        if(Value % (*It) == 0) return false;
    }
    return true;
}
TList GetPrimeList(TInt Max)
{
    TList Prime;
    Prime.reserve(Max);
    Prime.push_back(2);
    for(TInt i = 3; i <= Max; i += 2){
        if(IsPrime(i, Prime)){
            Prime.push_back(i);
        }
    }
    return Prime;
}
int main()
{
    TList List = GetPrimeList(999999);
    while(true){
        int n;
        std::cin >> n;
        if(std::cin.eof()) break;
        TList::iterator It = std::upper_bound(List.begin(), List.end(), n);
        std::cout << std::distance(List.begin(), It) << std::endl;
        
    }
    return 0;
}

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

using namespace std;

inline void era(vector<bool> &prime, int num);

using namespace std;

int main(void){
  int num;

  while(cin >> num){
    vector<bool> prime((num+1), true);
    prime[0] = false;
    prime[1] = false;
    era(prime, num);
    cout << count(prime.begin(), prime.end(), true) << endl;
  }
  return 0;
}

void era(vector<bool> &prime, int num){
  int N = 2;
  while (N <= num){
    int count = 2;
    while ((count*N) <= num){
      prime[count*N] = false;
      ++count;
    }
    ++N;
  }
}