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

#define MAX 1000000

int main( void )
{
	vector <bool> primes(MAX+1, false);

	for ( int i = 3; i <= MAX; i += 2 )
	{
		primes[i] = true;
	}

	for ( int i = 3; i <= MAX; i += 2 )
	{
		if ( primes[i] )
		{
			for ( int j = i + i; j <= MAX; j += i )
			{
				primes[j] = false;
			}
		}
	}
	primes[2] = true;
	
	int n;
	while ( cin >> n )
	{
		int cnt = 0;
		if ( n >= 2 )
			cnt++;
		for ( int i = 3; i <= n; i += 2 )
		{
			if ( primes[i] )
				cnt++;
		}
		cout << cnt << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
bool isprime(int& num)
{
    static int c;
    for(c=2; c <= sqrt(num)+1; c++)
        if(num % c ==0) return false;
    return true;
}

int main()
{
    int ans = 0;
    int buff;
    while(cin >> buff);
    {
        for(int d =2; d <= buff; d++)
            if(isprime(d)) ans++;
        cout << ans << " ";
        ans  = 0;
    }
    cout << endl;
    return 0;
}

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

C++: #include<stdio.h>
int prime[1000000];
int main(){
    prime[0]=-1;
    prime[1]=-1;
    for(int i=2;i<1000000;i++){
        if(prime[i]==0){
            prime[i]=1;
            for(int j=i*2;j<1000000;j+=i)prime[j]=-1;
        }
    }
    int now;
    while(~scanf("%d",&now)){
        int ans=0;
        for(int i=1;i<now+1;i++)if(prime[i]==1)ans++;
        printf("%d\n",ans);
    }

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[100000];
	int data[100000];
	int count;
	int premaxin=1;


	for(i=0;i<100000;i++){
		c[i]=1;
		data[i]=0;
	}
	c[0]=c[1]=0;

	while(scanf("%d",&n)!=EOF){

		if(premaxin<n){
			for(i=0;i<=n;i++){
				if(c[i]==1){
					if(premaxin>i){
						j=premaxin;
					}else{
						j=i+1;
					}
					for(;j<=n;j++){
						if(j%i==0){
							c[j]=0;
						}
					}
				}
			}

			count=data[premaxin];
			for(i=premaxin+1;i<=n;i++){

				if(c[i]==1){
					count++;
				}
				data[i]=count;
			}
		}

		printf("%d",data[n]);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,n[1000000],j,o=0;
	for(int i=2;i<=99999;i++){
		n[i]=1;
		
	}
	n[0]=n[1]=0;
		for( j=2;j<=99999;j++){
			if(n[j]){
				for(int k=j*2;k<=9999;k+=j){
				n[k]=0;
				}
			}
		}
		while(cin>>a){
	for(int k=2;k<=a;k++) if(n[k]) o++;
	cout<<o<<endl;
		}
}

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

int main()
{
	int n,i,j,count,pnum;
	while(scanf("%d",&n)!=EOF){
		count=0;
		pnum=0;
		
		
		for(i=n; i>=1; i--){
			for(j=1; j<=i; j++){
				if(i%j==0) count++;
			}
			if(count==2) pnum++;
			count=0;
		}
		cout << pnum << endl;
	}
	
	return 0;
}

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

using namespace std;

constexpr int ceil_sqrt(int x) {
  int ans = 0;
  while (ans*ans < x) { ++ans; }
  return ans;
}

template<int size>
struct Sieve {
  constexpr Sieve(): factor(), primes() {
    factor[0] = factor[1] = 1;
    for (int p = 2; p < size; ++p) {
      primes[p] = primes[p-1] + (factor[p]?0:1);
      if (factor[p]) { continue; }
      for (int n = 2*p; n < size; n += p) {
        factor[n] = p;
      }
    }
  }
  constexpr bool is_prime(int n) const {
    assert(n < size);
    return !(factor[n]);
  }
  int factor[size];
  int primes[size];
};

constexpr int NMAX = 1000010;

int main() {
  int N = 0;
  const auto sieve = Sieve<NMAX>();
  while (cin >> N) {
    cout << sieve.primes[N] << endl;
  }
  return 0;
}

C++: #include<stdio.h>

int main(void){
  int n;
  while(scanf("%d",&n)!=EOF){
    if(n==1){
      printf("0");
      break;
    }
    int p[100000];
    p[0]=2;
    int pi=1;
    int i=2;
    while(i<=n){
      int t=1;
      int j;
      for(j=0;j<pi;j++){
	if(i%p[j]==0){
	  t=0;
	  break;
	}
      }
      if(t==1){
	p[pi]=i;
	pi++;
      }
      i++;
    }
    printf("%d\n",pi);
  }
  return 0;
}

C++: /* AOJ0009 Prime Number */

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>

using namespace std;

const int N = 1e6;
const int SQRTN = ceil(sqrt((double) N));
bool isPrime[N + 1];
int prefixsum[N + 1];

// Eratosthenes筛选法
void esieve(void)
{
    memset(isPrime, true, sizeof(isPrime));

    isPrime[0] = isPrime[1] = false;
    for(int i=2; i<=SQRTN; i++) {
        if(isPrime[i]) {
            for(int j=i*i; j<=N; j+=i)  //筛选
                isPrime[j] = false;
        }
    }
}

void maketable()
{
    prefixsum[0] = 0;
    for(int i = 1; i <= N; i++)
        prefixsum[i] = isPrime[i] ? prefixsum[i - 1] + 1 : prefixsum[i - 1];
}

int main()
{
    esieve();

    maketable();

    int n;
    while(~scanf("%d", &n))
        printf("%d\n", prefixsum[n]);

    return 0;
}

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

int Era(int N) {
	int prime_num = 0;
	int* array = new int[N + 1];
	for (int i = 2; i < N + 1; i++) {
		array[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (array[i]) {
			for (int j = 0; i*(j + 2) <= N; j++) {
				array[i*(j + 2)] = 0;
			}
		}
	}
	for (int i = 2; i < N + 1; i++) {
		if (array[i])prime_num++;
	}
	return prime_num;
}

void add(int* primes, int& now,int prime) {
	primes[now] = prime;
	now++;
}

int main() {
	int num;
	int primes[1000]; int now = 0;
	while (cin >> num) {
		add(primes, now, Era(num));
	}
	for (int i = 0; i < now; i++) {
		cout << primes[i] << endl;
	}
	return 0;
}

C++: /*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp*/

#include <iostream>

#define MAX 999999

using namespace std;

int num_prime[MAX+1];
bool not_prime_flag[MAX+1];

int main()
{
    int n;

    for (int i = 2; i < MAX+1; ++i) {
        if(!not_prime_flag[i]){
            for (int j = 2; i*j < MAX+1; ++j) {
                not_prime_flag[i*j] = true;
            }
        }
        num_prime[i]=num_prime[i-1]+!not_prime_flag[i];
    }
    while (cin>>n){
        cout<<num_prime[n]<<endl;
    }
    return 0;
}

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

using namespace std;
int c = 0;
int i = 1;
unsigned long long a = 0;
unsigned long long b = 0;
unsigned long long sosuu[1000000] = { 0 };
int pattara = 0;

int sub(int c) {

	
	
	
	for (int i = 2; i<=c; i++){
		
		for (int q = 1; q <= sqrt(i); q++) {
			sosuu[pattara] = i;
			if (sosuu[pattara] % 2 == 0 && sosuu[pattara]!= 2) {
				break;
			}
			if (sosuu[pattara] % q == 0) {
				b += 1;
			}

		}

		if (b == 1) {
			
			pattara++;
			
		}
		b = 0;
		
	}

	
	return 0;
}


int main(){
	while (scanf("%d", &c) != EOF){

		sub(c);
		cout << pattara << endl;
		pattara = 0;
		
	}

	return 0;
}