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] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

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

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

bool number[1000000];

void prime() {
  FOR(i, 1, 1000000) number[i] = true;
  FOR(i, 2, 1000000) {
    if(number[i] == true) {
      for(int j = 2; i*j < 1000000; j++) {
	number[i*j] = false;
      }
    }
  }
}    


int main() {
  int n, count;

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

C++: #include<iostream>
using namespace std;
int PrimeNum(int n){
  for(int i = 2;i <= n;i++){
    if(i == n){
      return 1;
    }
    if(n % i == 0){
      return 0;
    }
  }
}
int main(){
  int n,num;
   while(cin >> n){
    num = 0;
     for(int k = 2;k <= n;k++){
       if(PrimeNum(k) == 1){
	 num = num +1;
       } 
     }
     cout << num << endl;
     }
}

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

int main() {
	vector<int> p;
	int n;
	p.push_back(2);
	for(int i=3;i<999999;i++){
		for(int j=0;;j++){
			if(i%p[j]==0)
			break;
			if(i<p[j]*p[j]){
			p.push_back(i);
			break;
			}
		}
	}
	p.push_back(9999999);
	while(cin >> n){
		int i=0;
		while(n>=p[i]){
			i++;
		}
		cout << i << endl;
	}
	return 0;
}

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

bool isPrime(int n){
	double sqrtN = sqrt(n);
	for(int i = 3; i <= sqrtN; i += 2){
		if(!(n%i))
			return false;
	}
	return true;
}
 
int main(){
  bool prime[999999] = {};
  prime[1] = true;
  for(int i = 3; i < 999999; i += 2){
  	if(isPrime(i))
  		prime[i-1] = true;
  }
  int n;
  while(cin >> n){
  	int count = 0;
  	if(n >= 2)
  		count++;
    for(int i = 3; i <= n; i += 2){
    	if(prime[i-1])
    		count++;
    }
    cout << count << endl;
  }
}

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

typedef unsigned int Int;

Int sqrt_prm(const Int& target, Int x = 0) {
	while (x*x < target) {
		x++;
	}
	return x;
}

int main() {
	while (not std::cin.eof()) {
		Int target;
		std::cin >> target;

		std::vector<Int> primes = {};
		Int sqrt = 1;
		for (Int n = 3; n <= target; n+=2) {
			bool flag = true;

			sqrt = sqrt_prm(n, sqrt);
			for (auto&& div : primes) {
				if (div < sqrt) { break; }
				if (n % div == 0) {
					flag = false;
					break;
				}
			}

			if (flag) {
				primes.push_back(n);
			}
		}

		std::cout << primes.size() + (target >= 2 ? 1 : 0) << std::endl;
	}
}

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

int p[MAX];

int main(){
	int counter = 0;
	p[1] = 0;
	for (int i = 2; i < MAX; i++){
		int sqrti = (int)sqrt(i);
		counter++;
		p[i] = counter;
		for (int j = 2; j <= sqrti; j++){
			if (i % j == 0){
				counter--;
				p[i] = counter;
				break;
			}
		}
	}
	int n;
	while (cin >> n){
		cout << p[n] << endl;
	}
	return 0;
}

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

int prime(int n) {
    if (n == 2) return 1;
    if (n % 2 == 0) return 0;
    for (int i = 3; i <= n / i; i += 2) {
        if (n % i == 0) return 0;
    }
    return 1;
}

int main() {

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

    int n;
    while (cin >> n) {
        cout << C[n] << endl;
    }

    return 0;
}

C++: #include<iostream>
using namespace  std;
bool isPrime(int p)
{
	bool flag = true;
	for (int i = 2; i * i <= p; i++)
	{
		if (p % i == 0)
		{
			flag = false;
			break;
		}
	}
	return flag;
}
int main()
{
	int n;
	while (cin >> n)
	{
		int count = 0;
		for (int i = 2; i <= n; i++)
		{
			if (isPrime(i))count++;
		}
		cout << count << endl;
	}
	return 0;
}

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

int main(void){
  int n;
  short int p[1000000];
  p[0] = p[1] = 0;
  p[2] = 1;
  int ans = 0;
  bool flag;
  for(int i = 3; i <= 1000000; i ++){
    if(i % 2 != 0){
      flag = true;
      for(int j = 3; j * j <= i; j += 2){
	if(i % j == 0){
	  flag = false;
          break;
	}
      }
      if(flag)
	ans++;
    }
    p[i] = ans;
  }
  // cout << "end" << endl;
  while(cin >> n){
    cout << p[n] << endl;
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

bool is_prime(int n)
{
	if (n == 2)
	{
		return true;
	}
	else if ((n == 1) || (n % 2 == 0))
	{
		return false;
	}

	int p = (int)sqrt(n);
	for (int i = 3; i <= p; i += 2)
	{
		if (n % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	vector<int> p;
	for (int i = 1; i < 1000000; i++)
	{
		if (is_prime(i))
		{
			p.push_back(i);
		}
	}

	int n;
	for (; cin >> n;)
	{
		int i;
		for (i = 0; i < p.size(); i++)
		{
			if (p.at(i) > n)
			{
				break;
			}
		}

		cout << i << endl;
	}
}