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++: //AOJ0009
//20170415
//????????°??\???????´???°?????°

#include <iostream>

using namespace std;

int main()
{
  int n;
  do {
    cin >> n;
  } while (n < 1 || 999999 < n); //n???????????\???
  
  int a[n];
  for (int i = 0; i < n; i++)
    a[i] = i + 1; //??°??¨?????\???(1~n?????§)

  for (int i = 0; i < n; i++) { //????????°?????????
    int q = i + 1;
    if (i != 0 && a[i] != 0) { //1??§???????????¨?????????????????????????????°??§???????????¨?????????
      for (int j = q; j < n; j++) {
	if (a[j] != 0) { //????????\???????´???°??§????????????????????°?????????
	  int r = a[j] % q;
	  if (r == 0)
	    a[j] = 0; //??????q??§??????????????????0?????£??\??????
	}
	else
	  continue;
      }
    }
    else
      continue;
  } //??¨????????????????????????

  int b = 0;
  for (int i = 0; i < n; i++)
    if (a[i] != 0)
      b++; //n??\???????´???°????????????????????????

  /*
  for (int i = 0; i < n; i++)
    cout << a[i] << " ";
  cout << '\n';
  */
  
  cout << b - 1 << '\n'; //??????
}

C++: #include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
bool prime[1000001];

typedef long long LL;
int main(){
        REP(i,1000001){
            prime[i]=true;
        }
        prime[0]=false;
        prime[1]=false;
        REP(i,1000001){
            if(prime[i]==false)continue;
            for(int j=2*i;j<1000001;j+=i){
                prime[j]=false;
            }
        }
        LL a;
        while(cin>>a){
           LL c=0;
           REP(i,a+1){
               if(prime[i]==true){
                  c++;
               }
           }
           cout<<c<<endl;
        }
	return(0);
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >> n){
    int ans=0,math[1000000]={0};
    math[1]=1;
    for(int i=2;i<n+1;i++){
      int bell=i;
      if(math[i]==0){
	ans++;
	math[i]=1;
      }
      while(bell<=n){
	bell+=i;
	if(math[bell]==0){
	  math[bell]=1;
	}
      } 
    }
    cout << ans << endl;
  }
}

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

int main(){
	while(1){
		int ans=0;
		int n;
		cin>>n;
		if(cin.eof())break;
		if(n==1){
			cout<<0<<endl;
		}else{
			if(n>=2)ans++;
			if(n>=3)ans++;
			if(n>=5){
				for(int i=5;i<=n;i+=2){
				    if(i%3!=0){
				        bool prime=true;
					    for(int k=2;k<=sqrt(i);k++){
						    if(i%k==0){
							    prime=false;
							    break;
    						}
					    }
					    if(prime)ans++;
				    }
				}
			}
		cout<<ans<<endl;
		}
	}
}

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

const int INF = 1 << 30;
const int MAX_PRIME = 1000010;
bool is_prime[MAX_PRIME + 10];
vector<int> primes;

void init_primes() {
    fill(is_prime, is_prime + MAX_PRIME + 10, true);
    is_prime[0] = is_prime[1] = false;
    for(int i=0; i<=MAX_PRIME; i++) {
        if(is_prime[i]) {
            primes.push_back(i);
            for(int k=i+i; k<=MAX_PRIME; k+=i) {
                is_prime[k] = false;
            }
        }
    }
}

int main() {
    init_primes();
    primes.push_back(INF);

    int N;
    while(scanf("%d", &N) != EOF) {
        printf("%zu\n", upper_bound(primes.begin(), primes.end(), N) - primes.begin());
    }
    return 0;
}

C++: #include<stdio.h>
#include<math.h>
#define MAX 10000
int main()
{
	int i, j,n,s;
	bool a[MAX];

	for (i = 0; i < MAX; i++) {
		a[i] = i <= 1 ? false: true;
	}
	for (i = 2; i < sqrt(MAX); i++) {
		if (a[i]) {
			for (j = 0; i*(j + 2) < MAX; j++) {
				a[i*(j + 2)] = 0;
			}
		}
	}
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &n);
	}
	s = 0;
	for (i = 0; i < n; i++) {
		s = s + a[i];
	}
	printf("%d",s);
}

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

int main()
{
	int counter=1,n,flag;
	
	while(cin>>n)
	{
		if(n<=1) 
		{
			cout<<'0'<<endl;
			break;
		}

		for(int i=3;i<=n;i+=2)
		{
			flag=1;
			for(int j=3;j<=sqrt(i);j+=2)
				if(i%j==0)
				{
					flag=0;
					break;
				}
			if(flag==1)
				counter++;
		}
		cout<<counter<<endl;
		counter=1;
	}
}

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

int main(void) {
    int N=999999;
    int p[N] , s[N];
    p[0]=0 , s[0]=0;
    for (int i=1; i<N; i++){
        p[i] = 1;
        s[i] = 0;
    }
    for (int i=1; i<N; i++){
        cout << i;
        if (p[i]==1){
            int n=i+1 , m=2*n;
            while (m<=N){
                p[m-1] = 0;
                m += n;
            }
        }
    }
    
    for (int i=1; i<N; i++){
        s[i] = s[i-1]+p[i];
    }
    int n;
    while (1){
        cin >> n;
        if (cin.eof())
            break;
        cout << s[n-1] << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
#define MAX 1000000

int main(){
	bool p[MAX+1];
	int n, ans;

	for(int i=0 ; i<=MAX ; i++){
		p[i] = (i<=1)? false : true ;
	}

	for(int i=2 ; i<=sqrt(MAX)+1 ; i++){
		if(p[i]){
			for(int j=i*2 ; j<=MAX ; j+=i){
				p[j] = false;
			}
		}
	}

	while( cin >> n ){		
		ans = 0;
		for(int i=0 ; i<=n ; i++){
			if(p[i]){
				ans++;
			}
		}
		cout << ans << endl;
	}
}

C++: #include<cstdio>
using namespace std;
#define MAX 1000000
int prime[MAX];
bool is_prime[MAX];
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;
}
int main()
{
  int num;
  while(scanf("%d",&num)!=EOF){
   printf("%d\n",sieve(num));
  }
  return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int data=1,i,j,s[1000000],x;

	while((scanf("%d\n",&data)) != EOF)
	{
		for(i=0;i<=data;i++){
			s[i]=1;}
		x=0;
		if(data<=1){
			printf("%d\n",0);}
		else
		{
			for(i=2;i<=data/2;i++)
				for(j=i*2;j<data;j+=i)
				    s[j]=0;		
		for(i=0;i<data;i++)
			x+=s[i];
		printf("%d\n",x);
		}
	}
  return 0;
}

C++: #include <cstdio>

using namespace std;

int main() {
    long NUM = 1000000;
    long n;
	long counter = 0;
	bool primeNum[NUM + 10];

	long i, ii, j, len = NUM + 10;
	
	primeNum[0] = primeNum[1] = false;
	for (i = 2; i < len; i++) primeNum[i] = true;
	
	ii = 4;
    for(i = 2; ii < NUM;) {
        if (primeNum[i]) {
            for (j = ii; j < NUM; j += i) {
                primeNum[j] = false;
            }
        }
        
        i++;
        ii = i * i;
    }
    
    while (scanf("%ld", &n) != EOF) {
        counter = 0;
        
        for (i = 0; i <= n; i++) {
            if (primeNum[i]) counter++;
        }
        
        printf("%ld\n", counter);
    }

    return 0;
}