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<stdio.h>
#include<math.h>
#define ullint unsigned long long int

// ?????°???(a^b %d ????¨????)
int modpow(ullint a, ullint b, long int d) {
  if (b == 0)     return 1;
  if (b % 2 == 0) return modpow(a*a % d, b/2, d);
  else            return a*modpow(a, b-1, d) % d;
}

// Miller???Rabin?´???°?????????
bool Miller_Rabin_Test(int n){
    int prime_list[4] = {2, 7, 61};

    if(n == 2 || n == 7 || n == 61){  // 2,7,61????´???°
        return true;
    }
    if(n == 1 || n%2 == 0){  // 2??\????????¶??°??¨1????´???°??§??????
        return false;
    }
    // n = 2^s*d + 1 (d????\???°)?????¢????????¢
    int d = n-1;
    int s = 0;
    while(d%2 == 0){  // d????\???°??????????????§?????¢
        d = d/2;
        s++;
    }
    for(int i=0; i<3; i++){  // ??????????????????3???
        bool isProbPrime = false;
        int a = prime_list[i];
        int r = modpow(a, d, n);
        if(r == 1 || r == n-1){
            isProbPrime = true;
            continue;
        }
        for(int j=0; j<s; j++){
            r = modpow(a, pow(2,j)*d, n);
            if(r == n-1){
                isProbPrime = true;
                break;
            }
        }
        if(!isProbPrime){
            return false;
        }
    }
    return true;
}

int Primenum[1000000];

int main(){
    Primenum[1] = 0;
    for(int i=1; i<=1000000; i++){
        if(Miller_Rabin_Test(i)){
            Primenum[i] = Primenum[i-1] + 1;
        }else{
            Primenum[i] = Primenum[i-1];
        }
    }
    for(int n; scanf("%d\n",&n) != EOF;){
        printf("%d\n",Primenum[n]);
    }
    return 0;
}

C++: #include<cstdio>
using namespace std;
#define MAX_N 999999+10
int prime[MAX_N];
bool is_prime[MAX_N+1];

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 n;
    while(~scanf("%d",&n)){
        printf("%d\n",sieve(n));
    }
}

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

int main(void)
{
  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;
    }
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
using namespace std;

int main(){
  int n,i,j;
  while(cin >> n) {
    
    int k = 0, a[n];
    a[0] = 2;
  
    for (i = 3; i <= n; i++) {
      for (j = 0; j <= k; j++) {
        if(i % a[j] == 0) break;
      }
      if(j == k + 1) {
        k++;
        a[k] = i;
      }
    }
    for(i = 0; i <= k; i++) {
      cout << a[i] << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int a[1000000];
int sum[1000000];
int n;
int main(){
 for (int i=2;i<1000000;i++){
  if (!a[i])
   for (int j=i*2;j<1000000;j+=i)
    a[j]=1;
 }
 for (int i=2;i<1000000;i++) sum[i]=sum[i-1]+(a[i]==0?1:0);
 while (cin>>n)
  cout<<sum[n]<<endl;
 return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
long n,i,j,*nn;
for(;;){
cin>>n;
if(cin.eof())break;
nn=new long [n+1];
nn[1]=0;nn[2]=1;
for(i=3;i<=n;i+=2)nn[i]=1;
for(i=4;i<=n;i+=2)nn[i]=0;
for(i=3;i*i<=n;){
for(j=i;i*j<=n;j+=2)nn[i*j]=0;
i++;while(nn[i]==0)i++;
}
for(i=2,j=0;i<=n;i++)if(nn[i]==1)j++;
cout<<j<<endl;
delete [] nn;
}
return 0;
}

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

using namespace std;

bool isPrime(int x);

int main(void) {
	int n;
	while(cin >> n) {
		
		int count = 0;
		for(int i = 1; i < n; i++) {
			if(isPrime(i))		count++;
		}
		
		cout << count << endl;
	}
	
	return 0;
}

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

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int MAX_N = 1000000;
int n;
int ptr;
bool isPrime[MAX_N+1];
int prime[MAX_N];

int main()
{
  prime[ptr++] = 2;
  for(int i=2; i<=MAX_N; i*=2) isPrime[i] = true;
  for(int i=3; i<=MAX_N; i+=2){
    if(!isPrime[i]){
      prime[ptr++] = i;
      for(int j=2*i; j<=MAX_N; j+=i){
        isPrime[j] = true;
      }
    }
  }

  while(cin >> n){
    cout << (upper_bound(prime, prime+ptr, n) - prime) << endl;
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
bool flg[1000000];
int main(void){
	int n;
	int i,j;
	int cnt=0;
	while(1){
		cin>>n;
		if(cin.eof())	break;
		fill(flg,flg+n,0);
		for(i=2;i*i<=n;i++){
			//cout<<"I="<<i<<endl;
			for(j=2;j<=n;j++){
				//cout<<"J="<<j<<endl;
				flg[i*j]=1;
			}
		}
		cnt=0;
		for(i=2;i<=n;i++)	if(flg[i]==0)	cnt++;
		cout<<cnt<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <limits>
#include <map>
#include <string>
using namespace std;

bool is_prime(int n){
for(int i=2;i*i<=n;i++){
if(n % i == 0) return false;
}
return n!=1;
}

int main(){
int n;
int* table =  new int[1000000];
while(~scanf("%d",&n)){

fill((int*)table,(int*)table+n+1,1);
table[0]=0;
table[1]=0;

for(int i=2;i<=n;i++){
if(table[i] && !is_prime(i)) {
for(int j=i;j<=n;j+=i){
table[j] = 0;
}
}
}
printf("%d\n",count(table,table+n+1,1));
}
}

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

int main(){
	int n;
	int sosu[10000];
	int snum;
	bool judge;

	sosu[0] = 2;

	while(cin >> n){
		snum = 0;
		for(int i = 3; i <= n; i++){
			judge = true;
			for(int j = 0; j <= snum; j++){
				if(i%sosu[j] == 0){
					judge = false;
					break;
				}
			}
			if(judge == true){
				snum ++;
				sosu[snum] = i;
			}
		}
		cout << snum + 1 << endl;
	}



	return(0);
}

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

const int N = 1000009;
int dp[N];
int isprime[N];

int main()
{
    dp[1] = 0;
    for(int i=2;i<N;i++)
    {
        if(!isprime[i])
            for(int j=2*i;j<N;j+=i)
                isprime[j] = 1;
        dp[i] = dp[i-1] + ((isprime[i])?0:1);
    }

    int y;
    while(~scanf("%d",&y))
        printf("%d\n",dp[y]);
    return 0;
}