Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := 2; j < MAX/i; j++ {
                                if i * j < MAX {
                                        primes[i*j] = 0
                                }
                        }
                }
        }
}

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

static void InputData(std::vector<int>& v)
{
	int n = 0;

	if (0x00 == &v) {
		std::cerr << "vec is null" << std::endl;
		return;
	}
	while (std::cin >> n) {
		v.push_back(n);
	}
}

static int getPrimeNumber(int n)
{
    int cnt = 0;

    for (int i = 2; i <= n; i++) {
	for (int j = 2; j <=i; j++) {

	    if (i == j) {
		cnt++;
	    }
	    if (0 == i % j) {
		break;
	    }
	}
    }

    return cnt;
}

static bool printPrimeNumber(std::vector<int>& v)
{
	if (0x00 == &v) {
		std::cout << "v is null" << std::endl;
		return false;
	}
	for (int i = 0; i < v.size(); i++) {
		std::cout << getPrimeNumber(v.at(i)) << std::endl;
	}

	return true;
}

int main()
{
	std::vector<int> vec;

	InputData(vec);
	printPrimeNumber(vec);

	return 0;
}

C++: /*
- Featured Article -
Reimu Hakurei is one of the main characters of the Touhou Project
series, having appeared in almost every game in the series.
As the sole maiden of the Hakurei Shrine, she is commonly called
upon (or calls it upon herself) to investigate strange occurrences
throughout Gensokyo. In earlier games, Reimu's spiritual abilities
were highly limited. (In Highly Responsive to Prayers, she was
unable to directly harm enemies at all.) As time passed, however,
she developed her abilities, becoming able to manipulate the
Hakurei Yin-Yang Orb, special amulets, and her own spiritual power
to fight more effectively. Sometime between Mystic Square and
Embodiment of Scarlet Devil, she realized...
*/
#include <bits/stdc++.h>
using namespace std;
#define N 1000000

int main(){
    bool cmp[N]={true};
    int npr[N];
    for(int i=2;i<N;i++){
        if(!cmp[i]){
            for(int j=2;i*j<N;j++)cmp[i*j]=true;
        }
        npr[i]=npr[i-1]+!cmp[i];
    }
    int data[30],i;
    for(i=0;cin>>data[i];i++);
    for(int j=0;j<i;j++){
        cout<<npr[data[j]]<<endl;
    }
}

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

	bool is_prime[1000000];
	int n_prime[1000000];
int main()
{
	
	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 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<cstdio>
using namespace std;
int main()
{
	int n,m,j,i,s;
	bool yes;
	while(cin>>n)
	{
		s=0;
		for(i=2;i<=n;i++)
		{
			if(i==2||i==3||i==5||i==7)s++;
			else if(i%2!=0&&i%3!=0&&i%5!=0&&i%7!=0)s++;
		}
		cout<<s<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
bool Eratosthenes[999999+30];

int main()
{
    int n,pos;
    int c;

    while(cin>>n)
    {
        c=0;
        Eratosthenes[1]=false;

        for(int i=2; i<=n; i++) Eratosthenes[i]=true;
        for(int i=2; i<=n; i++)
        {
            if(Eratosthenes[i]==true)
            {
                pos=2*i;
                while(pos<=n)
                {
                    Eratosthenes[pos]=false;
                    pos=pos+i;
                }
            }
        }
        for(int i=1; i<=n; i++)
        {
            if(Eratosthenes[i]==true)
                c++;
        }
        cout<<c<<endl;

    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#define F first
#define S second
using namespace std;
typedef pair<int, int> P;
const int INF = 1 << 30, Array = int(1e6);

int main(){

  int n, i, j, maxin = 2;
  bool jud;
  vector <int> vec;

  while(cin >> n){
    if(maxin < n){
      for(i = maxin;i <= n; i++){
        jud = 0;
        for(j = 0;  j < vec.size() ; j++){
          if(vec[ j ] * vec[ j ] > i) break;
          if( !( i % vec[ j ] ) ){
            jud = 1;
            break;
          }
        }
        if(!jud)
          vec.push_back( i );
      }
      maxin = n;
    }
    cout << upper_bound(vec.begin(), vec.end(), n) - vec.begin()   <<endl;
  }
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX_VALUE = 1000007;
bool prime[MAX_VALUE];

int main() {
  FOR(i, 2, MAX_VALUE){
    if(prime[i]) continue;
    for(int j = i * 2; j<MAX_VALUE; j+=i)
      prime[j]=true;
  }

  int n;
  while(cin >> n) {
    int cnt = 0;
    FOR(i, 2, n + 1){
      if (!prime[i]) cnt++;
    }
    cout << cnt << endl;
  }
}

C++: #include <iostream>
using namespace std;
void solve(int n);

int main() {
	int n;
	while (cin >> n) {
		if (n<=1) cout << 0 << endl;
		solve(n);
	}
	return 0;
}
void solve(int n) {
	int prime[n];
	int i=0;j=0;
	for (i=2; i<=n; i++) {
		prime[j] = i;
		j++;
	}

	int p;
	for (i=0; i<n; i++) {
		p = prime[i];
		if (p == -1) continue;
		
		for (int k=i+1; k<n; k++) {
			if (prime[k]%p == 0)
				prime[k] = -1;
		}
	}
	int count = 0;
	for (int i=0; i<n; i++)
		if (prime[i] != -1) count++;
	cout << count << endl;
}

C++: #include <stdio.h>
#include <string.h>
int main(void){
    int n=9999,a,b,c;
    char x[1000000];
    memset(x,0,sizeof(x));
    for(a=2,c=0;a<=n;a++){
        if(x[a]){x[a]=c;continue;}
        x[a]=++c;
        for(b=a*2;b<=n;b+=a)x[b]=-1;
    }
    while(~scanf("%d",&n)){
        printf("%d\n",x[n]);
    }
    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define M_PI 3.14159265358979
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include <algorithm>

using namespace std;

int yakusuu(int i){
	int counter=0;
	for (int j = 1; j <= i; j++){
		if (i%j == 0) counter++;
	}
	return counter;
}


int main()
{
	int n;
	
		
		while (scanf("%d",&n)!=-1)
		{
			int counter1 = 0;
			for (int i = 0; i <= n; i++)
			{
				if (yakusuu(i) == 2) counter1++;
			}

				cout << counter1 << endl;
		}
		
		
	return 0;
}

C++: #include <iostream>
using namespace std;
 
 bool IsPrime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i == 0){return false;}
    }
    return true;
}
 
 
int main(void) {
    int n;
 
    while(cin >> n){
    	for(i=2;i<=n;i++){
 　　		if(IsPrime(i)) count++;
 　	}
    	cout << count << endl;
    }
    
    return 0;
}