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 <vector>
using namespace std;
#define MAX 1000000
int main( void )
{
	vector <bool> primes(MAX+1, false);

	for ( int i = 3; i <= MAX; i += 2 )
	{
		primes[i] = true;
	}

	for ( int i = 3; i <= MAX; i += 2 )
	{
		if ( primes[i] )
		{
			for ( int j = i + i; j <= MAX; j += i )
			{
				primes[j] = false;
			}
		}
	}

	while ( !cin.eof() )
	{
		int n;
		cin >> n;
		if ( cin.eof() )
			break;

		int c = 0;
		if ( n == 2 )
			c = 1;
		else if( n < 2 )
			c = 0;
		else
		{
			c = 1;
			for ( int i = 3; i <= n; i += 2 )
			{
				if ( primes[i] )
					c++;
			}
		}

		cout << c << endl;

	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int a[1000000];
int sum[1000000];
int n;
int main(){
 for (int i=2;i<1000000;i++){
  if (!a[i])
   for (int j=i*2;j<1000000;j+=i)
    a[j]=1;
 }
 for (int i=2;i<1000000;i++) sum[i]=sum[i-1]+(a[i]==0?1:0);
 while (cin>>n)
  cout<<sum[n]<<endl;
 return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int mx = 1000010;
  vector<bool> isp(mx,true);
  isp[0]=false;
  isp[1]=false;
  REP(i,mx){
    if(isp[i]==false)continue;
    int t = i*2;
    while(t<mx){
      isp[t] = false;
      t += i;
    }
  }
  vector<int> sum(mx,0);
  REPR(i,mx) sum[i] = sum[i-1] + isp[i];
  int n;
  while(~scanf("%d",&n))cout<<sum[n]<<endl;
  return 0;
}

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

int main(void)
{
	bool prime[1000000];
	unsigned long n;

	for(unsigned long j = 2; j <= 999999; j++)
		prime[j] = true;
	for(int i = 2; i <= 1000; i++) {
		if(prime[i] == true) {
			for(unsigned long j = i * i; j <= 999999; j += i) {
				prime[j] = false;
			}
		}
	}

	while(cin >> n) {
		unsigned cnt = 0;
		for(unsigned long j = 2; j <= n; j++) {
			if(prime[j] == true) {
				cnt++;
			}
		}

		cout << cnt << endl;
	}
	return 0;
}

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

C++: #include<iostream>
#include<cmath>
using namespace std;
bool isprime(int n) {
	if (n == 2)return true;
	if (n % 2 == 0)return false;
	for (int i = 3; i <= sqrt(n); i += 2) if (n%i == 0)return false;
	return true;
}
int main() {
	int n; while(cin >> n){
		int sum = 0;
		for (int i = 1; i < n + 1; i++) {
			if (isprime(i))sum++;
		}
		cout << sum << '\n';
	}
	return 0;
}

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

bool isPrime(int a){
	int x = std::sqrt((double)a);
	for(;x>1;x--)
		if(a%x == 0)
			return false;
	return true;
}

int countPrime(int a){
	int x = a,ans = 1;
	if(x%2==0)
		x--;
	for(; x>1; x-=2)
		if(isPrime(x))
			ans++;
	return ans;
}

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

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

int p[1000010];

int main(){
	int n;
	int count;

	//エラトステネスの篩
	//素数のリストをつくる
	for (int i = 0; i <= 1000000; i++) p[i] = 1;
	p[0] = p[1] = 0;
	for (int i = 2; i*i <= 1000000; i++){
		if (p[i] == 1){
			for (int j = 2; i*j <= 1000000; j++){
				p[i*j] = 0;
			}
		}
	}

	//素数のカウント
	while (cin >> n){
		count = 0;
		for (int i = 0; i <= n; i++){
			if (p[i] == 1)count++;
		}
		cout << count << endl;
	}

	return 0;
}

C++: /*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

int main() {
	int a;
	int count;
	int ccount;
	vector<int> c = { 0 };
	while (cin >> a)
	{
		a = a + 1;
		count = 0;
		/*
		// ?´???°?????????
		// ??????????????°
		for (size_t i = 2; i < a; i++)
		{
			ccount = 0;
			// ????????°
			for (size_t j = 1; j <= i; j++)
			{
				//cout << "i= " << i << "j= " << j << endl;
				if (i % j == 0) {
					ccount++;
				}
			}
			if (ccount > 2) {
				count++;
			}
		}*/
		// ?????§????????§????????????0??§???????????????
		c.resize(a);

		
		// 2*i????????§????????§?????????????????????1?????????
		for (size_t i = 2; i < a; i++)
		{
			for (size_t j = 2; i*j < a; j++)
			{
				//cout << i*j << endl;
				c[i*j] = 1;
			}
		}
		// ??????????????????0??????????????°????????????
		for (size_t i = 0; i < a; i++)
		{
			if (c[i] == 0) {
				count++;
			}
		}
		cout << count-2 << endl;

		// ?¢??????¨
		
		for (size_t i = 0; i < a; i++)
		{
			cout << i << " = " << c[i] << endl;
		}
		
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;



int main(){
	int n; cin >> n;
	vi p(n + 1, 1);
	p[0] = p[1] = 0;
	int ans = 0;
	rep(i, n + 1) if (p[i]) {
		ans++;
		for (int j = i + i; j <= n; j += i) p[j] = 0;
	}
	cout << ans<< endl;
	return 0;
}

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

int main(){
    int n;
    while(cin>>n){
        if(n == 1) {
            cout<<0<<endl;
        }
        else if(n == 2){
            cout<<1<<endl;
        }
        else{
            int num[1000000] = {};
            for(int tmp = 2;tmp != n;tmp++){
                if(num[tmp] == 0)
                for(int i = tmp * 2;i <= n;i += i){
                    num[i] = 1;
                }
            }
            int count = 0;
            for(int i = 2;i != n;i++){
                if(num[i] == 0){
                    count++;
                }
            }
            cout<<count<<endl;
        }
    }
}