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>
#include<cmath>

#define N 1000000

using namespace std;

int main(){

  int n, root;
  int p[N][2] = {0};

  for(int i=2; i<N; i++){
    p[i][0] = 1;
  }

  for(int i=2; i<N; i++){
    root = (int)sqrt(i) + 1;
    for(int j=2; j<root; j++){
      if(p[j][0] == 1){
        if(i % j == 0){
          p[i][0] = 0;
          break;
        }
      }
    }
  }

  for(int i=2; i<N; i++){
    p[i][1] = p[i-1][1] + p[i][0];
  }

//  for(int i=0; i<30; i++){
//    cout << i << " " << p[i][0] << endl;
//  }

  while(cin >> n){
    cout << p[n][1] << endl;
  }

  return 0;
}

C++: #include <stdio.h>

int isPrime(int n);

int main(void){
    int n;
    int cnt;

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

    return 0;
}


int isPrime(int n){
    int i;
    
    if (n%2==0) return 0;
    for (i=2; i*i<=n; i++){
        if (n%i==0) return 0;
    }
    return 1;
}

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

const int NUM = 1000000;

int main() {
  int n;
  bool isPrime[NUM];
  int dp[NUM];
  for (int i=0;i<NUM;i++) {
    isPrime[i] = 1;
    dp[i] = 0;
  }
  isPrime[0] = isPrime[1] = 0;
  for (int i=2;i<NUM;i++) {
    if (isPrime[i]) {
      dp[i] = 1;
      for (int j=i*2;j<NUM;j+=i) {
        isPrime[j] = 0;
      }
    }
  }
  for (int i=1;i<NUM;i++) {
    dp[i] += dp[i-1];
  }

  while (cin >> n) {
    cout << dp[n] << endl;
  }
  return 0;
}

C++: 
#include<iostream>
using namespace std;
int sushu[1000010];
int n;
bool isPrime(int a){
	if (sushu[a] != -1){
		return sushu[a] == 0 ? false : true;
	}
	int i;
	for (i = 2; i < a; ++i){
		if (a%i == 0){
			sushu[a] = 0;
			return false;
		}
	}
	sushu[a] = 1;
	return true;
}
int main()
{
	memset(sushu, -1, sizeof(sushu));
	while (cin >> n){
		for (int i = 2; i <= n; ++i){
			if (isPrime(i))
				cout << i << endl;
		}
	}
	return 0;
}

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

int main(){
	int n;
	while(cin>>n){
		int cnt=0;
		vector<bool> v(n+1,true);
		for(int i=2; i<=sqrt(n); i++){
			if(v[i]){
				for(int j=2; i*j<=n;j++){
						v[i*j]=false;
				}
			}
		}
		for(int i=2;i<=n;i++){
			if(v[i])
				cnt++;
		}
		cout << cnt << endl;
	}
}

C++: #include <cstdio>

int main(void) {
	int n, ans = 0;
	scanf("%d", &n);
	for(int i = 2; i < n; i++) {
		bool flag = false;
		for(int j = 2; j < i; j++) {
			if(i % j == 0)
				flag = true;
		}
		if(flag)
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
vector<bool> GetPrimeTable(int n)
{
	vector<bool> IsPrimeNumber(n+1, true);
	for(int i = 2; i <= n; i++){
		while(IsPrimeNumber[i] == false){
			i++;
		}
		for(int j = 2; i*j <= n; j++){
			IsPrimeNumber[i*j] = false;
		}
	}
	return IsPrimeNumber;
}

int GetPrimeCount(vector<bool>& PrimeTable, int n)
{
	int Count = 0;
	for(int i = 2; i <= n; i++){
		if(PrimeTable[i] == true){
			Count++;
		}
	}
	return Count;
}

int main()
{
	vector<bool> PrimeTable = GetPrimeTable(999999);
	while(true){
		int Nubmer;
		cin >> Nubmer;
		if(cin.eof() == true) break;
		cout << GetPrimeCount(PrimeTable, Nubmer) << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n;
	int count;
	while (1)
	{
		cin >> n;
		if (cin.fail()) break;

		bool *isPrime;
		isPrime = new bool[n + 1];
		memset(isPrime, true, sizeof(bool) * (n + 1));
		isPrime[0] = isPrime[1] = false;
		
		count = 0;
		for (int i = 2; i <= n; ++i)
		{
			for (int j = i + i; j <= n; j += i)
			{
				isPrime[j] = false;
			}
		}
		for (int i = 0; i <= n; ++i)
		{
			if (isPrime[i] == true)
				++count;
		}
		cout << count << endl;
		delete[] isPrime;
	}
	return 0;
}

C++: #include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main() {
	const int MAX_V = 1000000;
	int prime[MAX_V+1];
	int i, k, v;
	for(i = 2; i <= MAX_V; i++) {
		prime[i] = 1;
	}
	for(i = 2; i*i <= MAX_V; i++) {
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0;
			}
		}
	}
	scanf("%d", &v);
	int count = 0;
	for(i=0;i<=v;i++){
		int isprime = prime[i];
		if(isprime) count ++;
	}
	printf("%d",count);
	return 0;
}

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

const int size = 1000000;
int n[size];

int main() {
    for(int i = 0 ; i < size ; ++i) {
		n[i] = (i < 2) ? false : true;
	}
    for (int i = 0; i < std::sqrt(size); ++i) {
        if (n[i]) {
            for (int j = 2; i * j < size; ++j) {
                n[i * j] = false;
            }
        }
    }
    
    int m;
    while (~scanf("%d\n", &m)) {
        int ans = 0;
        for (int i = 0; i <= m; ++i) {
            if (n[i]) {
                ++ans;
            }
        }
        printf("%d\n", ans);
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

// Eratosthenesの篩
vector<bool> primeno(1000010, true);
void Eratosthenes(int n) {
    primeno.at(0) = primeno.at(1) = false;
    int limit = sqrt(n);
    for(int i = 2; i < limit; ++i) {
        if(primeno.at(i)) {
            for(int j = 0; i*(j+2) < n; ++j) {
                primeno.at(i*(j+2)) = false;
            }
        }
    }
}

vector<int> primecnt(1000010, 0);

int main() {
    Eratosthenes(1000000);
    ll n;
    for(int i = 0; i < 1000000; ++i) {
        if(primeno.at(i)) primecnt.at(i)++;
        primecnt.at(i+1) += primecnt.at(i);
    }
    while(cin >> n) {
        cout << primecnt.at(n) << endl;
    }
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
int n;
while(cin >> n,!cin.eof()){
vector<int> prime;
prime.push_back(2);//ôðÈ­½ß2ÍÅÉüêÄ¨­
bool flag;
for(int x=3;x<=n;x+=2){
flag=true;
for(int y=0;prime[y]*prime[y]<=x;y++){
if(!(x%prime[y])){
flag=!flag;
break;
}
}
if(flag)prime.push_back(x);
}
cout << prime.size() << endl;
}
return 0;
}

C++: #pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	memset(vis, 0, sizeof(vis));
	memset(prime, 0, sizeof(prime));
	prime[0] = prime[1] = 0;
	for (int i = 2; i*i<= MAX; i++){
		if (!vis[i]){
			prime[i] = 1;
			for (int j = i + i; j <= MAX; j += i){
				vis[j] = 1;
				prime[j] = 0;
			}
		}
	}
	int sum = 0;
	for (int i = 0; i <= MAX; i++){
		if (prime[i]){
			sum++;
		}
		amount[i] = sum;
	}
	int n;
	while (cin >> n){
		cout << amount[n] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int tmp;
	while (cin >> tmp)
	{
		vector<int> prime;

		for (int i(2); i <= tmp; ++i)
		{
			for (vector<int>::iterator i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2)
			{
				if ((i % *i2) == 0)
				{
					goto nx;
				}
			}

			prime.push_back(i);
		nx:;
		}

		cout << prime.size() << endl;
	}

	return 0;
}