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 <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

constexpr ll NOT_SPECIFIED_VALUE_MIN = INT64_MIN;
constexpr ll NOT_SPECIFIED_VALUE_MAX = INT64_MAX;

template <typename T>
vector<bool> eratosthenes(T n) {
	vector <bool> IsPrime;
	if (n + 1 > IsPrime.size()) {
		IsPrime.resize(n + 1, true);
	}
	IsPrime[0] = false;
	IsPrime[1] = false;

	for (T i = 2; i*i <= n; i++) {
		if (IsPrime[i]) {
			for (T j = 2; i*j <= n; j++) {
				IsPrime[i*j] = false;
			}
		}
	}
	return IsPrime;
}

int main() {
	vector<bool> isPrime = eratosthenes(1LL << 20);
	vector<ll> numPrime((1LL << 20) + 1, 0);
	ll now = 0;
	for (ll i = 1; i <= (1LL << 20); i++) {
		if (isPrime[i] == true) {
			now++;
		}
		numPrime[i] = now;
	}

	ll n;
	n = -1;
	while (true) {
		cin >> n;
		if (n == -1)break;
		cout << numPrime[n] << endl;
		n = -1;
	}


}

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

int main()
{
	vector<int> pcount;
	int prime[10000];
	int j, k, x, num,count=0;
	while (cin >> num){
		prime[0] += 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[k++];
				count++;
			}
		}
		pcount.push_back(count);
		count = 0;
	}
	for (int i = 0; i < pcount.size(); i++)
	{
		cout << pcount[i] << endl;
	}
	return 0;
}

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

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

int solve(int x){
    int m = 0;
    for(int i=0;i<=x;i++){
        if(isprime(i)){
            m++;
        }
    }
    return m;
}
int main(){
    int n;
    cin >> n;
    cout << solve(n) << endl;
    return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = 998244353;
const double EPS = 1e-9;

bool s[1000000] = {};
int sosu[1000000] = {};
void erast(){
  memset(s,1,sizeof(s));
  s[1] = false;
  s[0] = false;
  REP(i,2,1000){
    if(s[i]){
      REP(j,2,1000000){
        if(i*j>=1000000) break;
        s[i*j] = false;
      }
    }
  }
  REP(i,2,1000000) sosu[i] = sosu[i-1]+s[i];
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    erast();
    int n;
    while(cin >> n,n){
      cout << sosu[n] << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstring>

using namespace std;
const int N=999999;
bool isprime[N+1];
int sum[N+1];

int main()
{
    memset(isprime,true,sizeof(isprime));
    for(int i=2;i<N/2;i++)
        for(int j=2*i;j<N;j+=i)
            if(isprime[i]) isprime[j]=false;
    isprime[0]=isprime[1]=false;
    memset(sum,0,sizeof(sum));
    for(int i=2;i<N;i++)
    sum[i]=sum[i-1]+isprime[i];

    int n;
    while(cin>>n)
    {
        cout<<sum[n]<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cmath>
#include <math.h>

using namespace std;

int SUUZI[1000000];

int a=0,b,d,f,n,c=0;
double buffer;

int main(){

	for(d=0;d<1000000;d++){SUUZI[d]=1;};
	
		for(a=3;a<1000000;a++){
			buffer=a;
				for(b=2;1;b++){
					if(a%b==0){SUUZI[a]=0;break;};
					if(b>sqrt(buffer)){SUUZI[a]=1;break;};
				};
};


while(cin>>n){
	c=0;
for(d=0;d<=n;d++){c+=SUUZI[d];};

cout<<c-2<<endl;

};
return 0;

}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;

const int SIZE = 1000001;
bool is_prime[1000001];
vector<int> primes;
int main()
{
	fill(is_prime, is_prime+SIZE, true);
	for (int i = 2; i < SIZE; ++i)
	{
		if (is_prime[i])
		{
			for (int j = 2*i; j < SIZE; j += i)
				is_prime[j] = false;
			primes.push_back(i);
		}
	}

	int n;
	while (scanf("%d", &n) != EOF)
		printf("%d\n", upper_bound(primes.begin(), primes.end(), n) - primes.begin() - 1);

	return 0;
}

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

constexpr int N = 999999;
vector<bool> primes( N+1, true );

void make_table() {
	primes[0] = false;
	primes[1] = false;

	int nr = (int)sqrt( N );
	for( int i = 2; i <= nr; ++i ) {
		if( primes[i] ) {
			for( int j = i+i; j <= N; j += i ) {
				primes[j] = false;
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio( false );

	make_table();

	int n;
	while( cin >> n ) {
		cout << count( primes.begin()+1, primes.begin()+1 + n, true ) << endl;
	}
}

C++: #include<stdio.h>
const int MAX_V=1000000;
int prime[MAX_V+1];
int sum[MAX_V+2];
int main(){
  int i,k,n;
  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;
      }
    }
  }
  for(i=0;i<MAX_V+1;i++){
    sum[i+1]+=sum[i]+prime[i];
  }
  while(scanf("%d",&n)!=EOF){
    printf("%d\n",sum[n+1]);
  }
  return 0;
}

C++: #include	<stdio.h>

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

int main(int argc, char** argv){
	
	int search, counter;
	
	while((scanf("%d", &search)) != EOF){
		counter = 0;
		for(int i = 2; i <= search; i++){
			counter += isPrimeNumber(i) ? 1 : 0;		
		}
		printf("%d\n", counter);
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll max_n = 1e6+4; 
void solve(){
    ll p = 0;
    ll Prime[n];
    ll isPrime[n+1];
    for(int i=0 ; i<=n ; i++){
        isPrime[i] = true;
    }
    isPrime[0] = isPrime[1] = 0;
    for(int i=2 ; i<=n ; i++){
        if(isPrime[i]){
            p++;
            for(int j=2*i ; j<=n ; j+=i){
                isPrime[j] = false;
            }
        }
    }
    cout << p << endl;
}

int main(){
    while (cin >> n, cin.eof() != true){
        solve();
    }
    return 0;
}