Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		input := nextInt()
		fmt.Println(IsPrime(input))
	}
}

func IsPrime(num int) int {
	eratos := make([]bool, num+1)
	c := 0
	for i := 2; i < len(eratos); i++ {
		if eratos[i] == false {
			c++
			eratosCalc(i, eratos)
		}
	}
	return c
}

func eratosCalc(primeNum int, eratos []bool) {
	for i := primeNum * primeNum; i < len(eratos); i += primeNum {
		eratos[i] = true
	}
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

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

#define maxPN 100000
#define PNs  1000100
int countPN = 0, countPNs = 0;
int PrimeNum[maxPN], temp;
bool PN[PNs];

bool IsPrimeNumber(int x);

void PrimeN(){
	int i, j;
	PrimeNum[0] = 2;
	PN[2] = true;PrimeNum[countPN++] = 2;
	PN[3] = true;PrimeNum[countPN++] = 3;
//	PN[5] = true;PrimeNum[countPN++] = 5;
	
	for(i = 6; i  < PNs;i+=6){
		if(IsPrimeNumber(i-1)){
			PrimeNum[countPN++] = i-1;
			PN[i-1] = true;//cout<<i-1<<endl;
		}
		if(IsPrimeNumber(i+1)){
			PrimeNum[countPN++] = i+1;
			PN[i+1] = true;//cout<<i+1<<endl;
		}
		countPNs = i+1;//cout<<i-1<<" "<<PN[i-1]<<endl;
	}
}

bool IsPrimeNumber(int x){
	//if(x == 2 || x == 3) return true;
	//if(x <= 4 || x%2 == 0 || x%3 == 0)   return false;
	//if(x < countPNs) return PN[x];
	for(int i = 0; PrimeNum[i] * PrimeNum[i] <= x; i++)
		if(x%PrimeNum[i] == 0)return false;
	return true;
}


int main(){
//	clock_t start, end;
	int n = true, counta;
//	start = clock();
	PrimeN();
	cout<<PrimeNum[countPN-1]<<" "<<countPNs<<endl;
//	cout<<clock()-start<<"ms"<<endl;
	
	while(cin>>n){
		counta = 1;
		
		
		//cout<<(IsPrimeNumber(n)?"yes":"no")<<endl;
	//	start = clock();
		//cout<<IsPrimeNumber(n)<<endl;
		for(int i = 1; i <= n; i+=2){
			if(PN[i])counta++;
		//	cout<<i<<" "<<PN[i]<<endl;
		}
		if(n == 1) counta = 0;
		cout<<counta<<endl;
	//	cout<<clock()-start<<"ms"<<endl;
	}
	return 0;
}

C++: #include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <cmath>
#include <complex>
#include <algorithm>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>
#include <valarray>
#include <list>

using namespace std;

typedef long long ll;

template<class T>
struct Pi {
    T x, y;
    Pi() {}
    Pi(T xx, T yy) {
        x = xx; y = yy;
    }
    bool operator<(const Pi &r) const {
        if (x != r.x) return x < r.x;
        return y < r.y;
    }
    bool operator>(const Pi &r) const {
        if (x != r.x) return x > r.x;
        return y > r.y;
    }
    bool operator==(const Pi &r) const {
        if (x != r.x) return false;
        return y == r.y;
    }
};

template<class T>
struct Ti {
    T x, y, z;
    Ti() {}
    Ti(T xx, T yy, T zz) {
        x = xx; y = yy; z = zz;
    }
    bool operator<(const Ti &r) const {
        if (x != r.x) return x < r.x;
        if (y != r.y) return y < r.y;
        return z < r.z;
    }
    bool operator>(const Ti &r) const {
        if (x != r.x) return x > r.x;
        if (y != r.y) return y > r.y;
        return z > r.z;
    }
    bool operator==(const Ti &r) const {
        if (x != r.x) return false;
        if (y != r.y) return false;
        return z == r.z;
    }
};

const int MN = 1000010;
bool isP[MN];
int main() {
    for (int i = 2; i < MN; i++) {
        bool f = true;
        for (int j = 2; j*j <= i; j++) {
            if (!(i%j)) {
                f = false;
                break;
            }
        }
        isP[i] = f;
    }
    int n;
    while (cin>>n) {
        int res = 0;
        for (int i = 0; i <= n; i++) {
            if (isP[i]) res++;
        }
        printf("%d\n", res);
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#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--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    FOR(i,3,250000){
	bool flg = true;
	REP(j,primes.size()) if(i % primes[j] == 0 ) {
	    flg = false;
	    break;
	}
	if(flg) primes.PB(i);
    }

    int n;
    while(true){
	cin >> n;
	if(cin.eof())break;
	int res = upper_bound(ALL(primes),n) - primes.begin();
	cout << res << endl;
    }

    return 0;
}

C++: // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009
// for ref

#include <iostream>
#include <cstring>
#include <cmath>
#define Rep(i, b, e)\
    for (int i = (int)b; i < (int)e; i++)

using namespace std;

const int MAXN = 999999;
bool isPrime[MAXN];

int countPrime(int n) {
    memset(isPrime, true, sizeof isPrime);
    Rep(i, 0, 1000)
        isPrime[i] = true;

    isPrime[0] = false;
    isPrime[1] = false;
    // isPrime[2] = true;
    // isPrime[3] = true;

    // Rep(i, 2, sqrt(n)+1) {
        //Rep (k, 2, sqrt(n)+1) {
    Rep(i, 2, n) {
        Rep(k, 2, n) {
            if (i*k > n)
                break;
            isPrime[i*k] = false;
        }
    }

    int primeCount = 0;
    int j = 0;
    // while (primeCount < n) {     // GS q
    while (j <= n) {
        if (isPrime[j]) {
            // cout << primeCount << " th prime\t";
            // cout << j << endl;
            primeCount++;
        }
        j++;
    }

    return primeCount;
}

int num;

int main()
{
    while (cin >> num) {
        cout << countPrime(num) << endl;
    }
 //   cout << "Hello world!" << endl;
    return 0;
}

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


int main(){
  int prime[1000000];
  fill(prime,prime+1000000,1) ;
  prime[0] = prime[1] = 0;
  for(int i = 2 ; i*i < 1000000 ; i++ ){
    if(prime[i])for(int j = i*2; j <1000000; j+=i)prime[j] = 0;
  }

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

C++: #include<iostream>
using namespace std;
int main(){
	int N,count=0;
	while(cin >> N){
	for(int x=2;x<=N;x++){
		int flag = 0;
		for(int y=2;y<x;y++){
			if((x%y)==0)	flag = 1;
		}
		if(flag == 0)	count++;
	}
	cout << count << endl;
	}
	return 0;
}

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

int main(){
  int a,cou,j;
  while(cin >> a){
    if(a>2){
      cou=0;
      for(int i=3;i<=a;i+=2){
	for(j=3;j*j<=i;j+=2){
	  if(i%j==0)break;
	}	  
	if(j*j>i)cou++;
      }
      cout << cou+1 << endl;
    }else cout << "1"<< endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


const int Max=10000000;
bool prime[Max];
int main(void){
    int in;
    for(int i=0;i<Max;i++)prime[i]=true;
    prime[1]=false;
    for(int i=2;i<Max;i++){
        if(prime[i]){
            for(int s=i*2;s<=Max;s+=i)prime[s]=false;
        }
    }
    while(cin>>in){
        int cnt=0;
        for(int i=1;i<=in;i++){
            if(prime[i])cnt++;
        }
        cout << cnt << "\n";
    }
    return 0;
}