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

bool isPrimeNumber(const unsigned long n);

int main(){
    unsigned long n;
    vector<unsigned long> pri;
    while(cin>>n){
        unsigned ans = 0;
        for(unsigned long i=1;i<=n;i--){
            bool serch = true;
            vector<unsigned long>::iterator it = pri.begin();
            while(it!=pri.end()){
                if(fmodl(n,*it)==0){
                    break;
                    serch = false;
                }
            }
            if(isPrimeNumber(i)&&serch){
                ans++;
                pri.push_back(i);
            }
        }
        cout << ans << endl;
    }
}

bool isPrimeNumber(const unsigned long n){
    static const unsigned long carn[]{
        561,	1105,	1729,	2465,	2821,	6601,	8911,
        10585,	15841,	29341,	41041,	46657,	52633,	62745,	63973,	75361,
        101101,	115921,	126217,	162401,	172081,	188461,	252601,	278545,	294409,
        314821,	334153,	340561,	399001,	410041,	449065,	488881,	512461,	530881,
        552721,	656601,	658801,	670033,	748657,	825265,	838201,	852841,	997633,
        1024651,1033669,1050985,1082809,1152271,1193221,1461241,1569457,1615681,
        1773289,1857241,1909001,2100901,2113921,2433601,2455921,2508013,2531845,
        2628073,2704801,3057601,3146221,3224065,3581761,3664585,3828001,4335241,
        4463641,4767841,4903921,4909177,5031181,5049001,5148001,5310721,5444489,
        5481451,5632705,5968873,6049681,6054985,6189121,6313681,6733693,6840001,
        6868261,7207201,7519441,7995169,8134561,8341201,8355841,8719309,8719921,
        8830801,8927101,9439201,9494101,9582145,9585541,9613297,9890881
    };

    if(n==2)
        return true;
    else if(n<2||n%2==0)
        return false;
    else{
        for(unsigned long i=0;i<sizeof(carn)/sizeof(carn[0]);i++){
            if(n<carn[i])
                break;
            if(n==carn[i])
                return false;
        }
        for(unsigned long i=n-1;i>0;i--){
            if(fmodl(powl(i,n),n)!=i)
                return false;
        }
        return true;
    }
}

C++: #include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
   int a,pp[100000];
   pp[0]=-1,pp[1]=-1;
   for(int i=2;i<100000;i++){
       if(pp[i]==0){
           pp[i]=1;
           for(int j=i*2;j<100000;j+=i){
               pp[j]=-1;
           }
       }
   }
   int now;
   while(cin>>now){
       int ans=0;
       for(int i=1;i<now+1;i++){
           if(pp[i]==1){
               ans;
           }
       }
       cout<<ans<<endl;
   }
    return 0;
}

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

int main()
{
    int n;
    
    while(cin >> n)
    {
        int sum = 0;
        if(n > 2)
            sum=1;
        
        for(int i=3; i<=n; i++)
        {
                bool flag = true;
                for(int j=2; j<i; j++)
                {
                        if(i % j == 0)
                            flag = false;
                }
                if(flag == true)
                        sum++;
        }
        cout << sum << endl;
    }
    
    return 0;
}

C++: #include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
int prime[1000001];
main(){
    int N;
    while(cin >> N){
        fill(prime,prime+1000001,0);
        for(int i = 2;i*i <= N;i++){
            if(prime[i])continue;
            for(int j = i*2;j <= N;j+=i){
                prime[j] = 1;
            }
        }
        int cnt = 0;
        for(int i = 2;i <= N;i++)if(!prime[i])cnt++;
        cout << cnt << endl;
    }
}

C++: #include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
#define N 1000000

int main(void)
{
    bool a[N];
    int n, count;
    rep(i,N)
        a[i] = true;
    a[0] = a[1] = false;
    for(int i=0;i*i<=N;i++)
    {
        if(a[i])
            for(int j=i*i;j<N;j+=i)
                a[j] = false;
    }
    
    while(cin >> n)
    {
        count = 0;
        
        rep(i,n+1)
        {
            if(a[i])
                count++;
        }
        cout << count << endl;
    }
    
    return 0;
}

C++: #include <iostream>
#include <cstring>
using namespace std;
#define maxn 1000000

int  isprime(int n)
{
  
  int p = 0;
  memset(prime,true,sizeof(prime));
  prime[0] = prime[1] = false;
  for(int i=2;i<=n;i++)
  {
    if(prime[i])
    {
      for(int j=2*i;j<=n;j+=i) prime[j] = false;
      p++;
    }
  }

  return p;
}

int main()
{
     
    int n;
    while(cin>>n)
    {
      bool prime[maxn];
	  cout<<isprime(n)<<endl;
    }
    return 0;
}

C++: #include <stdio.h>
int prime[999999];
int main()
{
    long long n,i,j,k,cou;

    prime[0]=prime[1]=1;
    for(i=2;i*i<=999999;i++)
    {

        if(prime[i]==0)
    {
        for(j=i+i;j<999999;j+=i)
        {
            prime[j]=1;
        }
    }
    }
    while(scanf("%lld",&n)==1)
    {
        cou=0;
        for(k=1;k<=n;k++)
        {
            if(prime[k]==0)
                cou++;
        }
        printf("%lld\n",cou);
    }

    return 0;

}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>

#define sf scanf
#define pf printf

using namespace std;

const int Maxn = 1000010;
int prime[Maxn];
int flag[Maxn];
int cnt ;
void _init()
{
    for(int i = 2;i < Maxn;i ++)
    {
        if(flag[i] == 0)
        {
            prime[cnt++] = i;
            for(int j = i * 2;j < Maxn;j += i)
                flag[j] = 1;
        }
    }
}
int Find(int n)
{
    int l = 0,r = cnt;
    while(l <= r)
    {
        int mid = (l + r) / 2;
        if(prime[mid] <= n)
            l = mid + 1;
        else
            r = mid - 1;
    }
    return l;
}
int main()
{
    _init();

    int n;
    while(~sf("%d",&n))
    {
        pf("%d\n",Find(n));
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main( void )
{
	int n;
	cin >> n;

	if ( n <= 0 )
		cout << "0" << endl;
	
	vector <bool> p(n+1, true);

	p[0] = p[1] = false;
	for ( int i = 4; i <= n; i += 2 )
	{
		p[i] = false;
	}

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

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

	cout << kotae << endl;

	return 0;
}

C++: #include <stdio.h>
const int MAX_V = 1000000; // 100???????????????????f???????¢\????°???¬?????
int prime[MAX_V+1] ,cnt[MAX_V+1] = {0};
int main(){
		int k,i,n; // 1????????f???????C0????????f????????????????????¢
	for(i = 2; i <= MAX_V; i++) {
		prime[i] = 1; // 2???????£????f????????????°??????¨
	}
	for(i = 2; i <= MAX_V; i++) {
		cnt[i] = cnt[i-1];
		//printf("")
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0; // ???f??????2???{???????£????{?????????f????????????????????¢
			}
			cnt[i]++;
		}
	}
	while(scanf("%d",&n) != EOF){
		printf("%d\n",cnt[n]);
	}
	return 0;
}