Go: package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	//"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	for sc.Scan(){
		n := nextInt()
		fmt.Println(calc(n))
	}
}

func calc(n int)int{
	// エラトステネスで数え上げる
	// 最初から999999まで用意しておいて入力のたびO(1)で出すのとどっちが速いのかはわからん
	eratos := make([]bool, n+1)
	c := 0
	for i:=2; i<len(eratos); i++{
		if eratos[i] == false{
			c++
			for j:=i*i; j<len(eratos); j+=i{
				eratos[j]=true
			}
		}
	}
	return c
}

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

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

C++: #include <iostream>
#include <bitset>
#include <vector>
#include <cmath>
#define	MAXPRIME	999999
using namespace std;

typedef unsigned int uint;

void setPrimeFlag(bool *primeFlag, uint maxPrime) {
	uint sq = (uint)sqrt((double)maxPrime) + 1;
	for (uint i = 2; i <= maxPrime; ++i) { primeFlag[i] = true; }
	primeFlag[0] = primeFlag[1] = false;
	for (uint i = 2; i <= sq; ++i) {
		if (primeFlag[i]) {
			for (uint j = i + i; j <= maxPrime; j += i) {
				primeFlag[j] = false;
			}
		}
	}
}

void setPrimeArray(vector<uint> &primeArray, uint maxPrime) {
	bool *primeFlag = new bool[maxPrime + 1];
	setPrimeFlag(primeFlag, maxPrime);

	primeArray.clear();
	for (uint i = 2; i <= maxPrime; ++i) {
		if (primeFlag[i]) {
			primeArray.push_back(i);
		}
	}
	delete [] primeFlag;
}

int main() {
	vector<uint> primeArray;
	setPrimeArray(primeArray, MAXPRIME);

	for (;;) {
		uint n, num;
		cin >> n;
		if (cin.eof()) { break; }

		for (num = 0; num < primeArray.size() && primeArray[num] <= n; ++num);

		cout << num << endl;
	}

	return 0;
}

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

int pn[1000002];

int main(){
int n, Count;
cin.tie(0);
while(scanf("%d",&n)!=EOF){
Count=0;
memset(pn,0,n);
pn[0]=pn[1]=1;
for(int i=2;i<=n;i++) if(!pn[i]) for(int j=1;i*j<=n;j++) pn[i*j]=1;
Count=count(pn,pn+n,0);
cout<<Count<<endl;
}
return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
    int n;
    while (cin >> n){
        int result = 0;
        for (int i = 2; i <= n; i++){
            for (int j = 2; j <= i; j++)
            {
                if (i == j)result++;
                if (i%j == 0)break;
            }
        }
        cout << result << endl;
    }


    return 0;
}

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

int main() {
	int n;
	
	while (cin >> n) {
		bool prime[1000000];
		for (int i = 2;i <= n;i++) {
			prime[i] = true;
		}
		for (int i = 2;i <= sqrt(n);i++) {
			for (int j = i * 2;j <= n;j += i) {
				prime[j] = false;
			}
		}
		int count = 0;
		for (int i = 2;i <= n;i++) {
			if (prime[i] == true) count++;
		}
		cout << count << endl;
	}

}

C++: /// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009
/// http://www.tsg.ne.jp/TT/tsg/c/mansaku/P01.html
#include<cstdio>
#include<cmath>

int main(){
    int n, cnt=0;
    while(~scanf("%d", &n)){
        for(int i = 3; i<=n; i+=2){
            int k= 0;
            for(int j=3; j<sqrt(i); j+=2){
                if(i%j==0){
                    k=1;
                    break;
                }
            }
            if(k==0) cnt++;
        }
        printf("%d\n", cnt);

    }

    return 0;
}

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

int main(){
  int a;
  int i, j, k;
  int past=1, a_sqrt;
  int count;
  bool chk[1000000];

  for(i=1; i<1000000; i++) chk[i]=true;
  while(cin>>a){
    count=0;
    if(past>=a){
      for(i=1; i<=a; i++){
        if(chk[i]) count++;
      }
      printf("%d\n", count);
    }
    else {
      a_sqrt=(int)sqrt((double)a);
      for(i=2; i<=a_sqrt; i++){
        k=past/i;
        if(k<2) k=2;
        for(j=k; j<=a/i; j++){
          chk[j*i]=false;
        }
      }
      past=a;
      for(i=1; i<=a; i++){
        if(chk[i]) count++;
      }
      printf("%d\n", count);
    }
  }

  return 0;
}

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

int main(){
  bool prime[1000000] = {};
  int sum[1000000]; sum[0] = sum[1] = 0; sum[2] = 1;
  for(int i = 3 ; i < 1000000 ; i += 2 ){
    sum[i] = sum[i + 1] = sum[i - 1];
    if(!prime[i]){
      for(int j = i + i + i ; j < 1000000 ; j += i + i ){
        prime[j] = true;
      }
      sum[i]++;
      sum[i+1]++;
    }
  }

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

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

using namespace std;

int setPrimeNumberCount(int n) {
    int count = 0;
    vector<int> primeList;
    bool findList[n+1];
    
    if(n >= 2) {
        primeList.push_back(2);
        count++;
        
        for(int i = 2; i <= n; i++){
            findList[i] = false;
        }
        for(int i = 2; i <= sqrt(n); i++){
            if(findList[i]) {
                continue;
            }
            for(int j = i * 2; j <= n; j += i) {
                if(!findList[j]) {
                    findList[j] = true;
                }
            }
        }
    }
    for(int i = 3; i <= n; i += 2){
        if(!findList[i]) {
            primeList.push_back(i);
            count++;
        }
    }
    return count;
}

int main(void) {
    int n;
    int count = 0;
    
    while(cin >> n) {
        count = setPrimeNumberCount(n);
        cout << count << endl;
        count = 0;
    }
    return 0;
}

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

void count_Prime(int n);
int IsPrime(int num);


int main()
{
	int Data = 0;
	while (cin >> Data)
	{
		count_Prime(Data);
	}

	return 0;
}

void count_Prime(int n)
{
	int counter = 0,  i = 0;
	for (i = 2; i <= n; ++i)
	{
		counter += IsPrime(i);		
	}

	cout << counter << endl;

}

int IsPrime(int num)
{
	if (num < 2) return 0;
	else if (num == 2) return 1;
	else if (num % 2 == 0) return 0; // ??¶??°????????????????????????

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// ?´???°??§?????????
			return 0;
		}
	}

	// ?´???°??§??????
	return 1;
}

C++: #include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;

template<typename T>
bool is_prime(T _Num){
    if(_Num < 2)return false;
    if(_Num % 2 == 0){
        if(_Num == 2)return true;
        else return false;
    }
    bool prime = true;
    for(int i = 3; i <= sqrt(_Num); i += 2){
        if(_Num % i == 0){
            prime = false;
            break;
        }
    }
    return prime;
}

int main(){
    long long cnt = 0;
    vector<long long> prime(1010000, 0);
    for(int i = 1; i < 1010000; i++){
        if(is_prime(i))cnt++;
        prime[i] = cnt;
    }
    
    while(true){
        int n = 0;
        cin >> n;
        if(n == 0)break;
        cout << prime[n] << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long double lb;

const int INF=1<<27;
const int MOD=(int)1e9+7;

int main(void)
{
	int n[30];
	bool po[1000001];
	rep(i,1000001)po[i]=true;
	int prime[1000001]={0};
	po[0]=false;
	po[1]=false;
	int cnt;
	while(cin>>n[cnt]) cnt++;

	int m=0;
	rep(i,cnt) m=max(n[i],m);

	for(int j=2;j<=m;j++){
		if(po[j]){
			prime[j]=prime[j-1]+1;
			for(int k=1;j*k<=m;k++) {
				po[j*k]=false;
			}
		}else{
			prime[j]=prime[j-1];
		}
	}

	rep(i,cnt) cout << prime[n[i]] << endl;

        return 0;
}

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


int main(){
	int number,cnt=0;
	cin>>number;
	int* arr = new int[number+1];
	for (int i = 1; i <= number; i+=2)
	{
		arr[i-1]=0;
		arr[i]=1;
	}
	for (int i = 3; i < sqrt(number); i+=2)
		if (arr[i])
			for (int j = i+i; j <=number; j+=i)
				arr[j]=0;
	arr[2]=1;arr[1]=0;
	for (int i = 0; i <= number; i++)
		if (arr[i])
			++cnt;
	cout<<cnt;
}