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<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<sstream>
#include<fstream>
#include<vector>
#include<list>
#include<deque>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#include<utility>
#include<numeric>
#include<iterator>
#include<algorithm>
#include<functional>
#include<ctime>
#include<cassert>
using std::cin;
using std::cout;
using std::endl;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
#define FOR(i,init,len) for(int i=(init);i<(len);++i)
#define For(i,init,len) for(int i=(init);i<=(len);++i)
#define fi first
#define se second
#define pb push_back
#define is insert
namespace IO {
	inline char getchar() {
		static const int BUFSIZE=5201314;
		static char buf[BUFSIZE],*begin,*end;
		if(begin==end) {
			begin=buf;
			end=buf+fread(buf,1,BUFSIZE,stdin);
			if(begin==end) return -1;
		}
		return *begin++;
	}
}
inline void read(int &in) {
	int c,symbol=1;
	while(isspace(c=IO::getchar()));
	if(c=='-') { in=0;symbol=-1; }
	else in=c-'0';
	while(isdigit(c=IO::getchar())) { in*=10;in+=c-'0'; }
	in*=symbol;
}
inline int read() { static int x;read(x);return x; }
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
#define PA(name,init,len) cout<<#name"["<<(len-init)<<"]=";FOR(_,init,len) cout<<name[_]<<" \n"[_==(len-1)];
#define Pa(name,init,len) cout<<#name"["<<(len-init+1)<<"]=";For(_,init,len) cout<<name[_]<<" \n"[_==(len)];
#define PV(name) cout<<#name"="<<name<<'\n';

const int maxn=1e6+10;
int pr[maxn];
bool vis[maxn];
int n;

int main() {
#ifdef MengLan
	int Beginning=clock();
	//freopen("in","r",stdin);
	//freopen("out","w",stdout);
#endif // MengLan

    memset(vis,1,sizeof(vis));
    vis[0]=vis[1]=false;
    For(i,2,maxn) if(vis[i]){
        int j=i*2;
        while(j<=maxn) vis[j]=false,j+=i;
    }
    For(i,2,maxn) pr[i]=pr[i-1]+vis[i];
    while(scanf("%d",&n)==1) printf("%d\n",pr[n]);

#ifdef MengLan
	printf("Time: %d\n",clock()-Beginning);
    //system("pause");
#endif // MengLan
	return 0;
}

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

int main(void)
{
    bool a[N+1];
    int prime[N], n;
    rep(i,N)
    {
        a[i] = true;
    }
    a[0] = a[1] = false;
    for(int i=2;i*i<=N;i++)
    {
        if(a[i])
        {
            prime[i] = prime[i-1] + 1;
            for(int j=i*i;j<N;j+=i)
                a[j] = false;
        }
        else
            prime[i] = prime[i-1];
    }

    while(scanf("%d", &n)!=EOF)
        printf("%d\n", prime[n]);
    
    return 0;
}

C++: #include<stdio.h>
#include<float.h>
#include<vector>



int makePrimenumbers(int a, int ref_max, vector<int> primes){
	int temp;
	
	if(a<ref_max)return 0;

	temp = ref_max;
	ref_max=a;
	int i,k,isp=1;

	for(k=temp;k<ref_max;k++){
		for(i=0;i<primes.size();i++){
			if(k%primes[i]==0){
				isp=0;
				break;
			}
		}
		if(isp==1){
			primes.push_back(k);
		}
		isp=1;
	}
	return 0;
}

int countprime(int a, voctor<int> primes){
	int i;
	for(i=0;i<prime.size();i++)
		if(a<prime[i])
			break;
	return (i);
}

int main(void)
{
	vector<int> primes;
	int ref_max=2;
	int result;
	int a;
	while(scanf("%d",&a)!=EOF){
		makePrimenumbers(a, max_ref, primes);
		result = countprime(a, primes);
		printf("%d\n",result);
	}
  return 0;
}

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

int main(void){
  int n;
  short int p[1000000];
  p[0] = p[1] = 0;
  p[2] = 1;
  int ans = 0;
  bool flag;
  for(int i = 3; i <= 1000000; i ++){
    if(i % 2 != 0){
      flag = true;
      for(int j = 3; j * j <= i; j += 2){
	if(i % j == 0){
	  flag = false;
	}
      }
      if(flag)
	ans++;
    }
    p[i] = ans;
  }
  // cout << "end" << endl;
  while(cin >> n){
    cout << p[n] << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;
 
int main(){
int n,count,m_Prime;
 
while(cin >> n){
	int count = 0;
        int j=0;
        vector <int> array;
        
        for(int i=2;i<=n;i++){                  //探査配列の代入
                array.push_back(i);
                }
        
        while(m_Prime*m_Prime < n){
                m_Prime = 0;                                                    //m_Primeの初期化（最小を見つけたら素数探査から抜け出す為
                
                for(;j<=n-2;j++){                               //最小の素数を見つける。
                        while(array[j] == 0){j++;}
                        for(int k=2;k<=array[j];k++){					
                                if(array[j]%k==0 && array[j] != k)       break;
                                if(array[j] == k)       m_Prime = array[j];
                                
                                }
                        if(m_Prime != 0)        break;
                        }
                
                
                for(int l=0;l<=n-2;l++){                                //最小素数の倍数が入っている所を0にする。ただし、その数自体は放置
                        while(array[l] < m_Prime) {     l++;}
						if(array[l] == m_Prime) array[l] = 1;
                        if(array[l] % m_Prime == 0)     array[l] = 0;
                        }
               
                
                }
        
                
        for(int m=0;m<=n-2;m++){                                        //素数のカウント
                if(array[m]!=0) count++;
                }
        
        
        cout << count << endl;                                          //出力
        }
 
 
        
return 0;
}

C++: #include <stdio.h>

bool isPrime(int n);

int main(void){
    int n;
    int primes;
    
    while (scanf("%d", &n)!=EOF){
        primes = 0;
        for (int i=2; i<=n; i++){
            if (isPrime(i)) primes++;
        }
        printf("%d\n", primes);
    }
}

bool isPrime(int n){
    if (n==1) return false;
    if (n==2) return true;
    for (int t=3; t*t<=n; t+=2){
        if (n%t == 0) return false;
    }
    return true;
}

C++: #include<stdio.h>
#include<math.h>
int main()
{ long long int LAST;
while(scanf("%lld",&LAST)==1){
long long  int num,i,count=0, is_prime;
for(num = 3; num <= LAST; num += 2)
{
is_prime = 1;
for(i = 2; is_prime && i <= num / 2; i++)
{
is_prime = (num % i != 0);
}
count += (is_prime ? 1 : 0);
}

printf("%lld\n",count+1);}
return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n, cnt;	
	while(cin >> n){
		bool prime[n] ={false};
		prime[1] = true;
		
		// ??¨??????????????????????????????
		for(int j = 2; j*j <= n; j++){
			if(prime[j] == false){
				for(int k = j; k*j <= n; k++){
					prime[j*k] = true;
				}
			}
		}
		cnt = 0;
		for(int i = 1; i <= n; i++){
			if(prime[i] == false) cnt++;
		}
		
		cout << cnt << endl;
	}
}