Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [40]int
	var inputCount, primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		resultArr[inputCount] = primeCount
		if inputCount == 30 {
			break
		}
		primeCount = 0
		inputCount++
	}
	for _, v := range resultArr {
		fmt.Printf("%d\n", v)
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

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

static const int InputMaxLen = 6;
class PrimeNumber {
public:
    void Run();

private:
    bool readData();
    bool calcPrimeNumber();
    void printData();
    bool checkDigit(int num);

private:
    std::vector<int> inputDataList;
    std::vector<int> ouotputDataList;
};

void PrimeNumber::Run()
{
    if (!readData()) {
        std::cout << "Failed read value." << std::endl;
        return;
    }
    if (!calcPrimeNumber()) {
        std::cout << "Failed calc prime number." << std::endl;
        return;
    }
    printData();
}

bool PrimeNumber::readData()
{
    int val = 0;

    while (std::cin >> val) {
        if (!checkDigit(val)) {
            return false;
        }
        inputDataList.push_back(val);
    }

    return true;
}

bool PrimeNumber::calcPrimeNumber()
{
    unsigned int val = 0;
    int cnt = 0;
    for (unsigned int i = 0; i < inputDataList.size(); ++i) {
        val = inputDataList.at(i);
        cnt = 0;
        if (!checkDigit(val)) {
            return false;
        }
        if (val >= 2) {
            cnt++;
        }
        if (val >= 3) {
            cnt++;
        }
        for (unsigned int j = 4; j <= val; ++j) {
            for (unsigned int k = 2; k <= j; ++k) {
                if (j == k) {
                    cnt++;
                }
                else if (0 == j % k) {
                    break;
                }
            }
        }
        ouotputDataList.push_back(cnt);
    }

    return true;
}

void PrimeNumber::printData()
{
    for (unsigned int i = 0; i < ouotputDataList.size(); ++i) {
        std::cout << ouotputDataList.at(i) << std::endl;
    }
}
// Check the value whether 6 digit.
bool PrimeNumber::checkDigit(int num)
{
    int cnt = 0;

    while (num > 0) {
        cnt++;
        num /= 10;
    }
    if (cnt > InputMaxLen) {
        return false;
    }
    return true;
}

int main()
{
    PrimeNumber obj;

    obj.Run();
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int tmp;
	while (cin >> tmp)
	{
		vector<int> prime;

		for (int i(2); i <= tmp; ++i)
		{
			for (vector<int>::iterator i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2)
			{
				if ((i % *i2) == 0)
				{
					goto nx;
				}
			}

			prime.push_back(i);
		nx:;
		}

		cout << prime.size() << endl;
	}

	return 0;
}

C++: #include<cstdio>
#include<vector>
using namespace std;
int main(void){
	int n;
	vector<int> a;
	int c;
	a.push_back(2);
	a.push_back(3);
	for (int i = 2; i < 510000; i++){
		for (int j = 1; j < a.size(); j++){
			if (a[j] * a[j]>2*i+1){
				a.push_back(2*i+1);
				break;
			}
			if ((2*i+1)%a[j] == 0)break;
		}
	}

	while (scanf("%d", &n) != EOF){
		c = 0;
		for (int i = 0; a[i] <= n; i++)c++;
		printf("%d\n", c);
	}
	return 0;
}

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

int sosu(int num){
int i;



for(i=2;i<=sqrt((double)num);i++){
if(num%i==0)return 0;
}

if(num==4)return 0;

return 1;

}

int main(){
int n,i,count;

while(cin >> n){

for(i=2;i<=n;i++){
if(sosu(i)){ 
count++;
}
}

cout << count << endl;
i=2;count=0;
}


}

C++: #include<cstdio>

int main(){
	int f[1000001] = {};
	int n;

	for(int i = 2; i < 500001; i++){
		f[i * 2] = 1;
	}

	for(int i = 3; i <= 1000; i += 2){
		for(int j = 2; j * i <= 1000000; j++){
			f[i * j] = 1;
		}		
	}

	int sum;

	while(scanf("%d", &n) + 1){
		int sum = n - 1;
		for(int i = 2; i <= n; i++){
			sum -= f[i];
		}
		printf("%d\n", sum);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <cstdio>

using namespace std;

void Eratosthenes(vector<int> &S_List, vector<int> &P_List){
	while(1){
		vector<int>::iterator it = S_List.begin();
		P_List.push_back(*it);  //先頭を素数リストへ追加
		int num = *it;
		while (it != S_List.end()){
			if ((*it % num) == 0){
				it = S_List.erase(it); //探索リストから倍数を除外
			}
			else{
				++it;
			}
		}
		vector<int>::iterator P_it = max_element(P_List.begin(), P_List.end());
		double p_max_sqr = sqrt(*P_it);
		vector<int>::iterator S_it = max_element(S_List.begin(), S_List.end());
		if (S_List.empty() == true){
			return;
		}
		if (*S_it < p_max_sqr){
			return;
		}
		/*else{
			Eratosthenes(S_List, P_List);
		}*/
	}
}


void output(vector<int> ex){
	/*vector<int>::iterator it = ex.begin();
	while(it != ex.end()){
		cout << *it << endl;
		++it;
	}*/
	cout << ex.size() << endl;
}

int main(void){
	
	int num;
	while (cin >> num){
		/*clock_t start = clock(); */
		vector<int> S_List, P_List;
		if (num < 4){
			for (int i=2; i<num; ++i){
				S_List.push_back(i);
			}
		}
		else{
			int c = 1;
			S_List.push_back(2);
			S_List.push_back(3);
			while((6*c+1) <= num){
				S_List.push_back(6*c-1);
				S_List.push_back(6*c+1);
				++c;
			}
			if (6*c-1 <= num){
				S_List.push_back(6*c-1);
				}
		}
		Eratosthenes(S_List, P_List);
		output(P_List);
		/*clock_t end = clock();
		printf("%.4f[sec]\n",(double)(end-start)/CLOCKS_PER_SEC);*/
	}
	return 0;
}

C++: #include <iostream>
const int MAX_V = 1000000; // 100????????§?´???°??¨?????????
int prime[MAX_V+1]; // 1????´???°???0????´???°??§?????? 
int pcount[MAX_V+1];
int main() {
    int i, k,a,sum=0;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1; // 2??\????´???°??¨??????
    } 
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°2?????\????????°?´???°??§?????? 
            }
            
        } 
        
    }
    pcount[0]=0;
    pcount[1]=0;
    for(i=2;i<MAX_V;i++){
        if(prime[i]){
            sum++;
        }
        pcount[i]=sum;
    }
    for(i=0;i<30;i++){
        scanf("%d",&a);
        printf("%d\n",pcount[a]);
    } 

    return 0; 
    
}

C++: #include <cctype>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define LL long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

#define MAX_NUM 999999
vector<LL> vecsosuu;

void makesosuu(void){
	FOR(i, 2 ,MAX_NUM){
		bool flag = true;
		if(i == 2){
			vecsosuu.pb(i);
		}else if(i % 2 != 0){
			int j = 3;
			while(j <= sqrt(i)){
				if(i % j == 0){
					flag = false;
				}
				j += 2;
			}
			if(flag){
				vecsosuu.pb(i);
			}
		}
	}
}

LL sosuu(LL n){
	LL i = 0;
	while(n >= vecsosuu[i]) ++i;

	return i;
}

int main(){
	LL n;
	makesosuu();
	while(cin >> n){
		cout << sosuu(n) << endl;	
	}
}