Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func check(n int) int {
	eratos := make([]bool, n+1)
	cnt := 0
	for i := 2; i < len(eratos); i++ {
		if !eratos[i] {
			cnt++
			for j := i*i; j < len(eratos); j += i {
				eratos[j] = true
			}
		}
	}
	return cnt
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		fmt.Println(check(n))
	}
}

C++: #include <stdio.h>

bool isPrime(int n);

int main(void){
    int n;
    int primes;
    
    while (scanf("%d", &n)!=EOF){
        primes = 0;
        for (int i=2; i<=n; i++){
            if (isPrime(i)) primes++;
        }
        printf("%d\n", primes);
    }
}

bool isPrime(int n){
    if (n==1) return false;
    for (int t=2; t*t<=n; t++){
        if (n%t == 0) return false;
    }
    return true;
}

C++: #include"iostream"

using namespace std;
int sum;
int prime(int n) {
	if (n > 2 && !(n & 1) || n < 2)
		return 0;
	for (int i = 3; i*i <= n; i += 2)
		if (!(n%i))
			return 0;
	sum++;
	return 0;
}

int main()
{
	int n,t=1;
	int *p;
	while (cin >> n)
	{
		sum = 0;
		p = new int[n];
		for (int i = 1; i <= n; i++)
			p[i] = prime(i);
		cout << sum << endl;
		t++;
		if (t > 30)
			break;
	}
	return 0;
}

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

int main() {
	int N;
	while(cin >> N){
		int is_prime[N+1];
		is_prime[0]=0; is_prime[1]=0;
		for(int i=2;i<N+1; i++){
			is_prime[i]=1;
		}
		
		for(int s=2; s<N+1; s++){
		
		if(is_prime[s]==1){	
		for(int i=s*s; i<N+1; i+=s){
			is_prime[i]=0;
		}
}
		
		}
		int ans=0;
		for(int i=2; i<N+1; i++){
			ans+=is_prime[i];
		}
		cout << ans <<endl;
		
	}
	return 0;
}

C++: #include<stdio.h>
main(){
	int i,j,n,p[1000000];
	scanf("%d",&n);
	for(i=2;i<=n;i++)
		p[i]=1;
	for(i=2;i<n;i++)
		for(j=2;i*j<=n;j++)
			p[i*j]=0;
	j=0;
	for(i=2;i<n;i++)
		j+=p[i];
	printf("%d\n",j);
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
main(){
	int n,p[10001];
	for(int i=0;i<=10000;++i)p[i]=1;
	p[0]=0;p[1]=0;
	for(int i=2;i<=10000,i*i<10000;++i){
		for(int j=2;j<=10000;++j){
			if(p[i]==0)break;
			if(j%i==0 && i!=j)p[j]=0;
		}
	}
	while(cin>>n){
		int sum=0;
		for(int i=0;i<=n;++i)if(p[i]==1)++sum;
		cout<<sum<<endl;
	}
}

C++: #include <stdio.h>

int main(void){
int n;
while(scanf("%d",&n)!=EOF){
int count=0;
for(int m=2;m<=n;m++){
bool check=true;
for(int i=2;i<m;i++){
if(i!=m && m%i==0){
check=false;
}
}
if(check==true){
count++;
}
}
printf("%d",count);
}
return 0;
}

C++: #include <iostream>

int main() {
	int input;
	while (std::cin >> input) {

	int count = 0; // input??\???????????¶??°????????¨???????´???°???????¨?
	for (; input > 1; input--) {// input???1???????????????????????????????????¨???????????????
		/*
		 * 5
		 * 4
		 * 3
		 * 2
		 */
		bool fl = true;
		for (int i = 2; i < input; i++) // 1 < i < input ????????¶??????????????°????????§?????????
			/*
			 * 5 -> 2, 3, 4
			 * 4 -> 2, 3
			 * 3 -> 2
			 * 2 ->
			 */
			 // ?????????????????°????????¨??????????????????????????????
			if (!(input % i))
				fl = false;

		if (fl)
			count++;
	}

			std::cout << count << std::endl;
	}
}

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<iostream>
#include<stdio.h>
using namespace std;

bool p[1000010];
int input;

void erato(){
	fill(p, p+1000010, true);
	p[0] = p[1] = false;

	for(int i=0; i * i < 1000010; i++){
		if(!p[i]) continue;

		for(int j = i + i; j < 1000010; j += i){
			p[j] = false;
		}
	}
}

int main(){
	erato();
	int input;

	while(scanf("%d", &input) != EOF){
		int ans = 0;
		for(int i=0; i <= input; i++){
			if(p[i]) ans++;
		}
		cout << ans << endl;
	}
}

C++: //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009

#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
vector<int> prime;

void Prime() {
	prime.emplace_back(2);
	for (int i = 3; i <= 999999; i += 2) {
		bool f = false;
		for (int j = 3; j <= sqrt(i); j += 2) {
			if (i%j == 0) {
				f = true;
				break;
			}
		}
		if (!f) prime.emplace_back(i);
	}
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	Prime();
	int n;
	while (cin >> n) {
		cout << upper_bound(prime.begin(), prime.end(), n) - prime.begin() << endl;
	}
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,k,sum,check;
    int t=1;
    vector<int> prime;
    prime.push_back(0);
    prime.push_back(0);
    for(int i=2;i<1000000;i++){
        prime.push_back(1);
    }
    while(t<1000000){
        for(int j=t+1;j<=1000000;j++){
            if(prime[j]==1){
                t=j;
                for(k=2*j;k<=1000000;k+=j){
                    prime[k]=0;
                }
                break;
            }
            else if(j==1000000){
                t=1000000;
            }
        }
    }
    while(cin>>n){
        sum=0;
        for(check=1;check<=n;check++){
            if(prime[check]==1){
                sum+=1;
            }
        }
        cout << sum << endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	
	long int n,f,k,i;
	int count;
	bool chk;
	while(cin>>n){
		count=0;
		for(i=2;i<=n;i++){
		
			chk=0;
			f=i/2;
			k=2;
		
			while(f>=k){
				if((i%k)==0){
					chk=true;
					break;
				}
				k++;
			}
		
			if(chk==false){
				count++;
			}
		}
		cout<<count<<endl;
	}
}

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

int main()
{
	int n[30];
	int i=0;
	while(cin >> n[i]) i++;
		
	for (int k=0;k<i;k++){
		int s=1;
	
		for (int j=3;j<=n[k];j++){
				//judgement of prime number
				for(int m=2;m<j;m++){
					if(j%m==0){break;}
					if(m==j-1){s=s+1;}
				}
		}
	cout << s <<endl;
	}
	
    return 0;
}