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>
using namespace std;

bool IsPrime(int m){
    if(m==1){
        return(1);
    }else if(m==2){
        return(1);
    }else if(m%2==0){
        return(0);
    }else{
        for(int i=3;i*i<=m;i+=2){
            if(m%i==0)return(0);
        }
        return(1);
    }
}
int main(){
    int n;
    int r[30];
    for(int i=0;i<30;i++){
        r[i]=0;
    }
    int j=0;
    while((char)n!=' '){
        cin>>n;
        for(int i=1;i<=n;i++){
            if(IsPrime(i))r[j]++;
        }
        cout<<r[j]<<endl;
        j++;
    }
    return(0);
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
   
using namespace std;
   

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define rforeach(it, c) for (__typeof__((c).rbegin()) it=(c).rbegin(); it != (c).rend(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))
#define COPY(dest, src) memcpy(dest, src, sizeof(dest))
#define ten(n) ((long long)(1e##n))
#define bin(n) (1LL << (n))

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

template <class T> void sort(vector<T>& c) { sort(c.begin(), c.end()); }
template <class T> void uniq(vector<T>& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); }

template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
  
template <class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << "( " << p.first << ", " << p.second << " )"; return os; }
  
template <class T> void print(T a, int n, const string& deli = " ", int br = 1) { for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } while (br--) cout << endl; }
template <class T> void print(const T& c, const string& deli = " ", int br = 1) { foreach (it, c) { cout << *it; if (++it != c.end()) cout << deli;--it; } while (br--) cout << endl; }
template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {    if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; }
   
template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
#define trace(x) (cout << #x << ": " << (x) << endl)

bool valid(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }


typedef long long ll;
typedef pair<int, int> pint;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
  
const double PI = acos(-1.0);
const int mod = 1000000007;



class SegmentPrimeTable
{
private:
    vector<bool> table;
    ll lower, upper;
    int index(ll n) const
    {
        assert(lower <= n && n <= upper);
        return n - lower;
    }
public:
    void sieve(ll lower, ll upper)
    {
        assert(lower >= 0);
        this->lower = lower, this->upper = upper;

        ll len = upper - lower + 1;
        table.resize(len);
        fill(table.begin(), table.end(), true);

        vector<bool> p(sqrt(upper) + 128, true);
        if (lower == 0) table[index(0)] = false;
        if (lower <= 1) table[index(1)] = false;
        for (ll i = 2; i * i <= upper; ++i)
        {
            if (p[i])
            {
                for (ll j = i + i; j * j <= upper; j += i)
                    p[j] = false;
                for (ll j = max(i + i, (lower + i - 1) / i * i); j <= upper; j += i)
                    table[index(j)] = false;
            }
        }
    }

    bool is_prime(ll n) const { return table[index(n)]; }
    vector<ll> primes(ll low, ll up) const
    {
        vector<ll> p;
        for (ll i = low; i <= up; ++i)
            if (is_prime(i))
                p.push_back(i);
        return p;
    }
};
vector<bool> prime_table(int upto)
{
    vector<bool> p(upto + 1, true);
    p[0] = p[1] = false;
    for (int i = 2; i * i <= upto; ++i)
        if (p[i])
            for (int j = i + i; j <= upto; j += i)
                p[j] = false;
    return p;
}
int main()
{
    vector<bool> p = prime_table(ten(6));
    int s[ten(6)];
    for (int i = 1; i < ten(6); ++i)
        s[i] = s[i - 1] + p[i];
    int n;
    while (cin >> n)
        cout << s[n] << endl;
}

C++: #include <iostream>
#include <vector>
using namespace std;
vector <int> wow(100001);

bool prime(int m){
	if(m < 2)return false;
	if(m == 2)return true;
	if(m%2 == 0)return false;

	for(int i = 3; i*i <= m; i += 2){
		if(m%i == 0)return false;
	}
		return true;
}

int main(){

	for(int i = 0; i < 100001; ++i){
	if(prime(i)){
					wow[i] = 1;
				}else{
					wow[i] = 2;
				}
	}


	int n;
	
	while(cin >> n){
		int a=0;
		for(int i = 1; i <= n; ++i){
		if(wow[i] == 1){
				++a;
			}
	}
		cout << a << '\n';
	}
}

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

int main()
{
	int n, i, k, j, h;
	bool flag = false;

	for(i=0; i<30; i++)
	{
		cin >> n;
		h = 0;
		for(k = 2; k <= n; k++)
		{
			flag = false;
			for(j = 2; j <= sqrt(k); j++)
			{
				if(k % j == 0)
				{
					flag = true;
					break;
				}
			}
			if(flag == false)
				h++;
		}
		cout << h << endl;
	}
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int prime[333333],cur;
bool isprime[1000000];
int main()
{
	for(int i=2;i<=1000000;i++)
		if(!isprime[i])
		{
			prime[cur++]=i;
			for(long long j=1LL*i*i;j<1000000LL;j+=1LL*i)
				isprime[j]=1;
		}
	int n;
	while(~scanf("%d",&n))
		printf("%d\n",lower_bound(prime,prime+cur,n)-prime+(!isprime[n]));
	return 0;
}

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

int main(){
    long maxy = 200000;
    int prime[maxy];
    //ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
    
    for(int i = 0; i < maxy; i++){
        prime[i] = 1;
    }
    prime[0] = prime[1] = 0;
    for(int i = 2; i <= maxy; i++){
        if(prime[i] == 1){
            for(int j=i*2; j <= maxy; j+=i){
                prime[j] = 0;
            }        
        }
    }
    int n;
    while(cin >> n){
        int ans = 0;
        for(int i=0; (i <= maxy && i <= n); i++){
            if(prime[i] == 1){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}