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>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

vector<ll> isPrime;

vector<int> sieveOfEratosthenes(int n) {
    isPrime.resize(n + 1, true);
    isPrime[0] = false;
    isPrime[1] = false;
    vector<int> res;
    for (int i = 2; i <= n; i++) {
        if (isPrime[i]) {
            res.push_back(i);
            for (int j = i * 2; j <= n; j += i) {
                isPrime[j] = false;
            }
        }
    }
    return res;
}


void Main() {
    ll N;
    while (cin >> N) {
        cout << sieveOfEratosthenes(N).size() << '\n';
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

C++: #include <iostream>
 
int main(){
    int n, count;
    while(std::cin >> n){
        count = 0;
        for(int i=3; i<=n; i++){            // check whether i is a prime number greater than 3
            for(int j=2; j<i; j++){         // judge from whether j is an i's divisor
                if(i % j == 0)              // if j is an i's divisor
                    break;                  // exit the j-loop & start to check suc(i)
                if(j == i - 1)              // when the j-loop lasts until i-1
                    count++;                // j is a prime!
            }
        }
        if(n>=2)
            count++;                        // 2 is also a prime
        std::cout << count << std::endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
const int M = (1e6);
bool p[M];
void isPrime(){
  rep(i,M)p[i] = true;
  p[0] = p[1] = false;
  loop(i,2,M){
    if(p[i])
      for(int j = i + i ; j < M ; j += i)
	p[j] = false;
  }
}
int main(void){
  isPrime();
  int n;
  while(cin>>n){
    int res = 0;
    rep(i,n+1)res += p[i];
    cout<<res<<endl;
  }
}

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

using namespace std;
int main() {
  long n;
  vector<long> primes;
  primes.push_back(2);
  while (cin >> n) {
    if (n == 1) {
      cout << 0 << endl;
      return 0;
    }
    for (int i = 3; i <= n; i += 2) {
      bool prime = true;
      for (unsigned int j = 0; j < primes.size() && primes[j] * primes[j] <= n; j++)
        if (i % primes[j] == 0) {
          prime = false;
          break;
        }
      if(prime && find(primes.begin(), primes.end(), i) == primes.end()) {
        primes.push_back(i);
      }
    }
    int x = 0;
    for (long& e: primes)
      if (e <= n) x++;
    cout << x << endl;
  }
}

C++: #include <cstdio>
#define MAX 100000

int main(){
	int n;
	bool c[MAX]={true};
	int t[MAX];t[0] = 0;
	for(int i = 2;i < MAX;i++){
		for(int j = i;i*j < MAX;j++){
			c[i*j-1] = true;
		}
	}
	for(int i = 1;i < MAX;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;
}

C++: 
/* vo00_09.cpp */

#include <iostream>
using namespace std;

const int N = 1000000;
int prime[N];

void init();

int main()
{
	init();

	int n;
	while (cin >> n) {
		
		cout << prime[n] << '\n';

	}

	return 0;
}

void init()
{
	for (int i = 0; i < N; ++i) { prime[i] = 1; }

	prime[0] = prime[1] = 0;

	for (int i = 2; i < N; ++i) {
		if (prime[i])
			for (int j = i * 2; j < N; j += i) { prime[j] = 0; }
	}

	int count = 0;
	for (int i = 0; i < N; ++i) { if (prime[i]) { count++; } prime[i] = count; }
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

vector<int>primes;
void hurui(const int amax) {
	static bool flag = false;
	if (flag)return;
	vector<int>sos;
	sos = vector<int>(amax + 1, true);
	sos[0] = false; sos[1] = false;
	for (int i = 2; i <= amax; ++i) {
		if (sos[i]) {
			for (int j = 2 * i; j <= amax; j += i)sos[j] = false;
		}
	}
	for (int i = 0; i <= amax; ++i) {
		if (sos[i]) {
			primes.push_back(i);
		}
	}
	flag = true;
}

int main() {
	hurui(1e6 + 5);
	int num;
	while (cin >> num) {
		auto it = upper_bound(primes.begin(), primes.end(),num);
		cout << it - primes.begin() << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
int isprime(int x){
    if(x==2) return true;
    if(x<2||x%2==0) return false;
    else{
        int i=3;
        while(i<=sqrt(x)){
            if(x%i==0) return false;
            i = i+2;
        }
        return true;
    }
}
int main() {
    int n;
    while(cin >> n){
        int ans=0;
    for (int j=n; j>1; j--) {
        if(isprime(j)!=0) ans++;
    }
    cout << ans << endl;
    }
}

C++: #include <bits/stdc++.h>

using namespace std;

#define MAX 1000000

int main()
{
    vector<int> p;
    bool prime[MAX];
    fill(prime, prime + MAX, 1);
    prime[0] = prime[1] = 0;
    for (int i = 2; i < MAX; i++) {
        if (prime[i]) {
            p.push_back(i);
            for (int j = 2*i; j < MAX; j += i) {
                prime[j] = 0;
            }
        }
    }

    int N;
    while (cin >> N) {
        cout << upper_bound(p.begin(), p.end(), N) - p.begin() << endl;
    }
    return 0;
}

C++: #include <stdio.h>
const int MAX_V = 100000;
int prime[MAX_V+1],sum[MAX_V+2]={0};
int main(){
  int n;
  for(int i = 2;i <= MAX_V;i++){
    prime[i] = 1;
  }
  for(int i = 2;i * i <= MAX_V;i++){
    if(prime[i]){
      for(int k = 2* i;k <= MAX_V;k += i)
      prime[k]=0;
    }
  }
  for(int i = 2;i < MAX_V;i++){
    sum[i] +=sum[i-1]+prime[i];
  }
  while(1){
    scanf("%d",&n);
    printf("%d\n",sum[n]);
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
#define MAX 1000000
int main( void )
{
	vector <bool> prime( MAX, false );
	prime[2] = true;
	for ( int i = 3; i <= MAX; i++ )
	{
		prime[i] = true;
	}

	for ( int i = 3; i <= MAX; i += 2 )
	{
		if ( prime[i] )
		{
			for ( int j = i + i; j <= MAX; j += i )
			{
				prime[j] = false;
			}
		}
	}

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

		int cnt = 1;
		for ( int i = 3; i <= n; i += 2 )
		{
			if ( prime[i] )
			{
				cnt++;
			}
		}

		cout << cnt << endl;

	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int d[1000000]={},p[1000000]={};
void calc(){
	for(int i=2;i<1000000;i++){
		if(d[i]==0){
			for(int j=2;i*j<1000000;j++){
					d[i*j]=1;
			}
		}
	}
	for(int i=2;i<1000000;i++){
		if(d[i]==0)
		p[i]=p[i-1]+1;
		else
		p[i]=p[i-1];
	}
}
int main(){
	calc();
	int n;
	while(cin>>n,n){
		cout<<p[n]<<endl;;
	}
	return 0;
}