Go: package main

import "fmt"

func main() {
	const MAX = 1000000
	prime := make([]int, MAX, MAX)
	check := make([]int, MAX, MAX)
	count := make([]int, MAX, MAX)

	prime[0] = 1
	prime[1] = 1

	// prime init
	for i := 2; i < MAX; i++ {
		if check[i] == 1 {
			continue
		}

		if prime[i] == 0 {
			for j := i * 2; j < MAX; j += i {
				check[j] = 1
				prime[j] = 1
			}
		}
	}

	for i := 2; i < MAX; i++ {
		cnt := 0

		if prime[i] == 0 {
			cnt = 1
		}

		count[i] = count[i-1] + cnt
	}

	for {
		var input int
		inputCount, _ := fmt.Scanf("%d", &input)
		if inputCount != 1 {
			break
		}

		fmt.Println(count[input])
	}
}

C++: #include <iostream>

int main(void)
{
    int input;
    while(std::cin >> input){
        bool* table = new bool[input + 1]();
        for(int i=0; i <= input; ++i){
            if(i < 2){
                table[i] = true;
                continue;
            }
            if(table[i] == false){
                for(int j=2;i * j <= input;++j){
                    table[i * j] = true;
                }
            }
        }
        int count = 0;
        for(int i=0;i <= input;++i){
            if(table[i] == false){
                ++count;
            }
        }
        std::cout << count << std::endl;
        delete[] table;
    }
    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(cin >> n)
    {
        cout << prime[n] << endl;
    }
    
    return 0;
}

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

int main(){
	int i, j, n, num = 0, count = 0;

	while(cin >> n){
		count = 0;
		for(i = 2; i <= n; i++){
			num = 0;
			for(j = 1; j <= i; j++){
				if(i % j == 0) num ++;
			}
			if(num == 2) count ++;
 		}
		cout << count << endl;
	}

	return 0;
}

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

bool IsPrime(int x) {
  return true;  /* ダミー: 全て素数と判定 */
}

int main(void){
   int count = 0, n;
   cin >> n; /* n個整数を読む */
   for(int i = 0; i < n; i++) {
       int p;
       cin >> p;
       if(IsPrime(p)) {
         bool IsPrime(int n) {
    for(int i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            return false;
        }
    }
    return true;
}


       }
   }
   cout << count << endl;
   return 0;
}

C++: #include <iostream>
using namespace std;
#define MAX 1000000
/// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=666933#1
int main(){
    bool num[MAX];
    for(int i =2; i<MAX; i++) num[i] =true;

    for(int i=2; i*i < MAX; i++){
        for(int j=i; i*j <MAX;j++){
            num[i*j] =false;
        }
    }
    for(int n, count =0; cin >> n; cout << count <<endl, count=0){
        for(int i=2; i<=n; i++){
            if(num[i]) count++;
        }
    }
}

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

class Era{
    public:
    vector<int>prime;
    vector<int>imos;
    Era(int num = 0){
        if(num < 2)return;
        prime = vector<int>(num + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        for(int i = 2; i * i <= num; i++){
            if(prime[i] == 0)continue;
            for(int j = i + i; j <= num; j += i){
                prime[j] = 0;
            }
        }
        imos = vector<int>(num + 1, 0);
        for(int i = 1; i <= num; i++){
            imos[i] = imos[i - 1] + prime[i];
        }
    }
};

int main(){

    Era era(1000000);
    for(int x; cin >> x;)cout << era.imos[x] << 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 <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <iostream>

#define N 1000000L
bool num[N];

void furui(void){
  long int i;
  int divide;
  int rt = 1000;
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0L] = false;
  num[1L] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = (long int) divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(void){
  int c, i, j;
  long int k;
  char buf[7];
  long int n;
  long int count;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0; ;i++){
      c = getchar();
      if(c == EOF || c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == true) count++;
    }
    std::cout << count << std::endl;
    if(c == EOF) break;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main( void )
{
	int n;
	cin >> n;
	
	vector <bool> p(n, true);
	p[2] = true;
	for ( int i = 3; i * i < n; i += 2 )
	{
		if ( p[i] )
		{
			for ( int j = i+2; j < n; j += i )
			{
				p[j] = false;
			}
		}
	}

	int kotae = 1;
	for ( int i = 3; i < n; i += 2 )
	{
		if ( p[i] )
			kotae++;
	}

	cout << kotae << endl;

	return 0;
}

C++: #include <iostream>

int main() {
	// Prime Data Set
	char p[1000000] = {0};
	p[1] = 1;
	for( int i=2; i<500000; i++) if(!p[i]) for( int j=i+i; j<1000000; j+=i) p[j] = 1;
	
	int n;
	int sum;
	while( std::cin >> n) {
		sum = 0;
		for( int i=1; i<n; i++) {
			if(!p[i]) sum++;
		}
		std::cout << sum << std::endl;
	}
}

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

int main()
{
	int count=0,n;
	bitset<1000000> prime;
	prime.reset();

	while(cin>>n)
	{
		prime[0]=1;
		prime[1]=1;
		for(int i=2;i<=sqrt(n);i++)
			if(prime[i]==0)
				for(int j=i+1;j<=n;j++)
					if(j%i==0)
						prime[j]=1;
		for(int i=2;i<=n;i++)
			if(prime[i]==0)
				count++;
		cout<<count<<endl;
		count=0;
		prime.reset();
	}
}

C++: #include <iostream>
#include <cmath>
using namespace std;
bool IsPrime(int n)
{
	int s = floor(sqrt(n)+0.5);
	for(int i = 2;i<=s;i++)
		if(n%i==0)return false;
	return true;
}
const int maxn = 1000000;
int dp[maxn];
int main()
{
	for(int i = 2;i<=maxn;i++)
		if(IsPrime(i))
			dp[i] = dp[i-1]+1;
		else dp[i] = dp[i-1];
	int n;
	while(cin >> n)
		cout << dp[n] <<endl;
	return 0;
}

C++: #include <stdio.h>

const int MAX_V = 1000000;
int prime[MAX_V+1];
int main() {
    int i, k, v;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1;
    }
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]){
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0;
            }
        }
    }
    while(scanf("%d", &v) != EOF) {
        int cnt=0;
        for(i=2; i<=v; i++){
            if(prime[i]==1){
                cnt++;
            }
        }
        printf("%d\n",cnt);
    }
}

C++: #include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool isp[1000000]={};


void makeEra(){
    for(int i=2;i<=1000;i++){
        if( isp[i] ){
            for(int j=2;j<1000000/i;j++){
                isp[i*j]=false;
            }
        }
    }
}


int main(){
    rep(i,1000000)isp[i]=true;
    isp[0]=isp[1]=false;
    makeEra();
    
    int n;
    while(cin>>n){
        int c = 0;
        rep(i,n+1){
            if(isp[i])c++;
        }
        cout<<c<<endl;
    }
}