Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

C++: #include<stdio.h>
int isprime(int n){
  for(int i=2;i*i<=n;i++){
    if(n%i==0)return 0;
  }
  return 1;
}
int main(){
  int k,n,p,q;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(k=2;k<=n-2;k++){
      if(isprime(k)&&isprime(k+2)){
        p=k;
        q=k+2;
      }
    }
    printf("%d %d\n",p,q);
  }
  return 0;
}

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

int main() {
	int a;
	while (cin >> a) {
		int sosuu = 0;
		if (a > 1)sosuu++;
		if (a > 2)sosuu++;
		for (int b = 5; b <= a; b+=2) {
			for (int c = 3;; c+=2) {
				if (b%c==0)break;
				if ((c + 1)*(c + 1) > b) { sosuu++;   break; }
			}
		}
		cout << sosuu << endl;
	}
}

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

int main(){
	bool is_prime[1000000];
	
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<1000000;i++){
		is_prime[i]=true;
	}
	
	for(int i=2;i*i<1000000;i++){
		if(is_prime[i]){
			for(int j=i*i;j<1000000;j+=i){
				is_prime[j]=false;
				}
			}
		}
		
		int n_prime[1000000];
		
		int cnt=0;
		for(int i=0;i<1000000;i++){
			if(is_prime[i]){
				cnt++;
			}
			n_prime[i]=cnt;
		}
		
		while(true){
			int n;
			cin>>n;
			if(cin.eof())
				break;
				
			cout<<n_prime[n]<<endl;
		}
		
		return 0;
}

C++: 
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
#define GetAuto(_N,vect) {cin>>N;vect.resize(N);REP(i,_N){cin>>vect[i];}}
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
#define beginend(vec) (vec).begin(),(vec).end()


int main() {
	ll n;
	vector<ll> ans;
	while (cin>>n)
	{
		int prime;
		double sqrtmax = sqrt(n);
		vector<ll> primeVec, searchVec;
		FOR(i, 2, n+1) searchVec.push_back(i);
		do
		{
			prime = searchVec[0];
			primeVec.push_back(prime);
			auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });
			searchVec.erase(itr, searchVec.end());
		} while (prime<sqrtmax);
		ans.push_back(primeVec.size() + searchVec.size());
	}
	Foreach(i, ans) out(i);
	return 0;
}

C++: #include<stdio.h>
#include<math.h>
int gurobal[999999]={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>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
#define GetAuto(_N,vect) {cin>>N;vect.resize(N);REP(i,_N){cin>>vect[i];}}
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
#define beginend(vec) (vec).begin(),(vec).end()
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}


int main() {
	ll nn;
	map<ll, ll> ans;
	map<ll, bool> box;
	vector<ll> input, output;
	while (cin >> nn)
	{
		input.push_back(nn);
		box[nn] = false;
	}
	box[1] = true;
	ans[1] = 0;
	Foreach(n, input) {

		if (box[n]) {
			output.push_back(ans[n]);
			continue;
		}
		int prime;
		double sqrtmax = sqrt(n);
		vector<ll> primeVec, searchVec;
		FOR(i, 2, n + 1) searchVec.push_back(i);
		do
		{
			prime = searchVec[0];
			primeVec.push_back(prime);
			auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });
			searchVec.erase(itr, searchVec.end());
		} while (prime < sqrtmax);
		ans[n] = (primeVec.size() + searchVec.size());
		output.push_back(ans[n]);
		box[n] = true;
	}

	ShowAll(output);
	return 0;
}

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

bool isPrime(int k) {
    for(int i = 2; i < k/2; i++){
        if(k%i == 0) 
            return false;
    }
    return true;
}

int main() {
    int n;
    int count = 0;
    while(cin>>n) {
        for(int i = 2; i <= n;i++) {
            if(isPrime(i))
                count++;
        }
        cout<<count<<endl;
    }
    
    return 0;
}