Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func check(n int) int {
	eratos := make([]bool, n+1)
	cnt := 0
	for i := 2; i < len(eratos); i++ {
		if !eratos[i] {
			cnt++
			for j := i*i; j < len(eratos); j += i {
				eratos[j] = true
			}
		}
	}
	return cnt
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		fmt.Println(check(n))
	}
}

C++: #include<stdio.h>
#include<math.h>
int gurobal[1000001]={0};
int main(void)
{
	int n=0;
	int i=0,j=0;
	int heihoukon=0;
	int count=0;
	while(scanf("%d",&n)!=EOF)
	{
		count=0;
		gurobal[1]=0;
		for (i=2;i<=n;i++)
		{
			gurobal[i]=1;
		}
		(int)heihoukon=sqrt((double)n);
		for (i=2;i<=heihoukon;i++)
		{
			if (gurobal[i]!=0)
			{
				for (j=i*2;j<=n;j+=i)
				{
					gurobal[j]=0;
				}
			}
		}
		for (i=2;i<=n;i++)
		{
			if (gurobal[i]!=0)
			{
				count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

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

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

#define MAX_NUM (1000000)

static int getPrimeNum(int maxVal);

int main(void)
{
  int n;
  
  while (std::cin >> n) {
    std::cout << getPrimeNum(n) << std::endl;
  }
  
  return 0;
}

static int getPrimeNum(int maxVal)
{
  static int searchList[MAX_NUM] = {0};
  static int primeList[MAX_NUM] = {0};
  
  double sqMaxVal = sqrt((double)maxVal) + 1;
  
  for (int i = 2; i <= sqMaxVal; i++) {
    if (searchList[i] == 0) {
      searchList[i] = 1;
      primeList[i] = 1;
      for (int j = i + 1; j <= maxVal; j++) {
        if (j % i == 0) {
          searchList[j] = 1;
        }
      }
    }
  }
  
  for (int i = 2; i <= maxVal; i++) {
    if (searchList[i] == 0) {
      primeList[i] = 1;
    }
  }
  
  int count = 0;
  for (int i = 2; i <= maxVal; i++) {
    if (primeList[i] == 1) {
      count++;
    }
  }
  
  return count;
}

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

int main()
{
	long int n,m;
	while(cin>>n){
		long int i;
		int number[100000]={0};
		int ans=0;

		for(i=2;i<n;i++){
			if(number[i]==0){
				ans++;
				for(m=i;m<n;m+=i){
					number[m]=1;
				}
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 1e6+5;
int is_prime[N];

int prime(int n)
{
	for(int i = 0;i <= n;++i)	
		is_prime[i] = true;
	is_prime[0] = 1;is_prime[1] = false;
	int res = 0;
	for(int i = 2;i <= n;++ i)
	{
		if(is_prime[i])
		{
			++res;
			for(int j = i * 2;j <= n;j += i)
				is_prime[j] = false;
		}
	}
	return res;
}

int main()
{
	int n;
	while(cin >> n)	
		cout << prime(n) << endl;
	return 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;
}