Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := i*2; j < MAX; j+=i {
                                primes[j] = 0
                        }
                }
        }
}

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

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

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

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

C++: #include <bits/stdc++.h>
using namespace std;
 
int num[1000001];
 
void prime_num() {
  num[0] = 1;
  num[1] = 1;
  for ( int i = 2; i * i  < 1000001; i++ ) {
    if ( num[i] == 0 ) {
      for ( int j = i * 2; j < 1000001; j += i ) {
    num[j] = 1;
      }
    }
  }
}
 
int main() {
  int n;
  prime_num();
  while ( cin >> n ) {
    int cnt = 0;
    for ( int i = 2; i  <= n; i++ ) {
      if ( num[i] == 0 ) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

#define MAX_N 2000000
int prime[MAX_N];



int main(){
	prime[1] = 1;
	prime[2] = 0;
	prime[3] = 0;
	for(int i = 2; i<=MAX_N;i++){
		if(prime[i] == 0)
			for(int j=2*i;j<=MAX_N;j=j+i)
				prime[j] = 1;
	}
	
	int n;
	int num=0;
	while(true){
		if (cin.eof())
			break;
		cin >> n;

		for(int k = 1;k<=n; k++){
			if(prime[k]==0)
				num++;
		}
		cout << num << endl;
		num = 0;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int prime[1000000];
int main(){
    fill_n(prime,1000000,1);
    prime[0]=prime[1]=0;

    for(int i=2;i<1000000;i++){
        prime[i]+=prime[i-1];
        if(prime[i]==prime[i-1])continue;
        for(int j=i+i;j<1000000;j+=i)prime[j]=0;
    }

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

    return 0;
}

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

C++: #include<iostream>

using namespace std;

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

C++: #include <stdio.h>
#include <math.h>
#define MAX 1000000
//エラトステネスの篩
int main(){
    int mem[100000] = {2};
    bool list[MAX]={true,true};
    int set = 2,m = 1,j,x;
    while( set < sqrt( MAX )){
    	for( int i = set;i < MAX;i++ ) if( i % set == 0 ) list[i] = true;
    	for( int i = set;i < MAX;i++ ) if( list[i] == false ){ set = i,mem[m++] = i,list[i] = true;break; }
    }
    for( int i = set;i < MAX;i++ )if( list[i] == false ) mem[m++] = i;
    while( scanf( "%d",&x ) != EOF ){
        for( j = 0;mem[j] <= x && j < m;j++ );
        printf( "%d\n",j );
    }
    return 0;
}

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

int main() {
	int n, ans;
	while (cin >> n) {
		ans = 2;
		if (n == 2) { cout << "1" << endl; continue; }
		if (n == 3) { cout << "2" << endl; continue; }
		for (int i = 4; i <= n; i++) {
			if (i % 2 == 0 || i % 3 == 0) continue;
			if (i % 6 != 1 && i % 6 != 5) continue;
			for (int i = 5; pow(i, 2) <= n; i += 6)
				if (n % i == 0 || n % (i + 2) == 0) continue;
			ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: /*-*-coding:utf-8-*-*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <iterator>
#include <cmath>
#include <stack>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
  int n;

  while(cin >> n, !cin.eof()) {
    int ans = 0;
    int flag = 0;

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

C++: #include <stdio.h>
#include <algorithm>

using namespace std;

void set_prime_number(bool* array, int num) {

  fill(array, array + num, true);
  array[0] = array[1] = false;
  for (int i = 2; i < num; i++) {
    if (!array[i]) continue;
    for (int j = i * 2; j < num; j += i) {
      array[j] = false;
    }
  }

}

int main() {
  bool prime_number[999999];
  int num;
  int nump=0;
  int cnt=0;

	while(scanf("%d",&num)!=EOF){
	  set_prime_number(prime_number,num);
	 for (int i = 0; i < num+1; i++) {
		 if (prime_number[i]){cnt++;}
	 }
	 printf("%d ",cnt);
	 cnt=0;
	}


  return 0;
}

C++: #include <iostream>
using namespace std;
const int MAX_V = 1000000;
int prime[MAX_V+1];
int pcount[MAX_V];
int main() {
    int i, k,a,sum=0;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1; // 2??\????´???°??¨??????
    } 
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°2?????\????????°?´???°??§?????? 
            }
            
        } 
        
    }
    pcount[0]=0;
    pcount[1]=0;
    for(i=2;i<MAX_V;i++){
        if(prime[i]){
            sum++;
        }
        pcount[i]=sum;
    }
    for(i=0;i<30;i++){
        scanf("%d",&a);
        printf("%d\n",pcount[a]);
    } 

    return 0; 
    
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

int p[1000010];

int main(){
	p[0]=p[1]=1;
	rep(i,1000000){
		if(p[i]==0)
			for(int j=2*i;j<1000000;j+=i)
				p[j]=1;
	}
	int n;
	cin>>n;
	int r=0;
	rep(i,n)
	if(p[i]==0)r++;
	cout<<r<<endl;
	return 0;
}

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

int main(){
  bool is_prime[1000000];
  for(int i=0;i<1000000;i++){
    is_prime[i] = true;
  }
  is_prime[0] = false;
  is_prime[1] = false;
  
  for(int i=2;i<1000000;i++){
    if(is_prime[i]){
      for(int j=2*i;j<1000000;j += i){
	is_prime[j] = false;
      }
    }
  }
 
 int n,counter;
 while(cin >> n){
 counter = 0;
 
 for (int k = 1; k <= n; k++)
   if(is_prime[k]){
     counter++;
   }

 cout << counter << endl;
 }
 
 return 0;
}