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

bool isPrimeNumber(const unsigned long n);

int main(){
    unsigned long n;
    while(cin>>n){
        unsigned ans = 0;
        for(unsigned long i=n;i>0;i--){
            if(isPrimeNumber(i)){
                ans++;
            }
        }
        cout << ans << endl;        
    }
}

bool isPrimeNumber(const unsigned long n){
    static const unsigned long carn[]{
        561,	1105,	1729,	2465,	2821,	6601,	8911,
        10585,	15841,	29341,	41041,	46657,	52633,	62745,	63973,	75361,
        101101,	115921,	126217,	162401,	172081,	188461,	252601,	278545,	294409,
        314821,	334153,	340561,	399001,	410041,	449065,	488881,	512461,	530881,
        552721,	656601,	658801,	670033,	748657,	825265,	838201,	852841,	997633,
        1024651,1033669,1050985,1082809,1152271,1193221,1461241,1569457,1615681,
        1773289,1857241,1909001,2100901,2113921,2433601,2455921,2508013,2531845,
        2628073,2704801,3057601,3146221,3224065,3581761,3664585,3828001,4335241,
        4463641,4767841,4903921,4909177,5031181,5049001,5148001,5310721,5444489,
        5481451,5632705,5968873,6049681,6054985,6189121,6313681,6733693,6840001,
        6868261,7207201,7519441,7995169,8134561,8341201,8355841,8719309,8719921,
        8830801,8927101,9439201,9494101,9582145,9585541,9613297,9890881
    };

    if(n==2)
        return true;
    else if(n<2||n%2==0)
        return false;
    else{
        for(unsigned long i=0;i<sizeof(carn)/sizeof(carn[0]);i++){
            if(n<carn[i])
                break;
            if(n==carn[i])
                return false;
        }
        for(unsigned long i=n-1;i>0;i--){
            if(fmodl(powl(i,n),n)!=i)
                return false;
        }
        return true;
    }
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

bool t[1000000];

int main(){
	memset(t,1,sizeof(t));
	t[0] = t[1] = false;
	for(int i = 2; i < 1000; i++){
		if(t[i])
			for(int j = 2 * i; j < 1000000; j += i){
				t[j] = false;
			}
	}

	int n;
	while(cin>>n){
		int ans = 0;
		for (int i = 0; i <= n; i++)
		{
			ans += t[i];
		}
		cout << ans << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n;
  vector<int> v;
  while (cin >> n) {
    if (v.size() > n) {
      cout << accmulate(v.begin(), v.end() - (v.size() - n), 0) << endl;
    }
    v.resize(n + 1);
    fill(v.begin(), v.end(), 1);
    v[0] = 0;
    v[1] = 0;
    for (int i = 0; i * i < v.size(); ++i) {
      while (v[i] == 0) ++i;
      for (int m = i + 1; m < v.size(); ++m) {
        if (m % i == 0) {
          v[m] = 0;
        }
      }
    }
    cout << accumulate(v.begin(), v.end(), 0) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>

using namespace std;

int main(void){
  const int n = 1000000;
  bool* check_A = (bool*)malloc(sizeof(bool)*n);
  int*  num_A   = (int*)malloc(sizeof(int)*n);
  int N = 0, temp = 2;
  memset(check_A, true, n);
  check_A[0] = false;
  check_A[1] = false;
  num_A[0] = 0;
  num_A[1] = 0;
  for(int i = 0; i < n; i++){
    if(check_A[i]){
      for(;temp < i;temp++){
	num_A[temp] = N;
      }
      temp++;
      num_A[i] = ++N;
      for(int j = 2; i*j < n; j++){
	check_A[i*j] = false;
      }
    }
  }
  int s;
  while(cin >> s){
    cout << num_A[s] << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int n,i,j;
    int ans;

    while(cin >> n){ 
        ans=0;
        for(i=2;i<=n;i++){
            for(j=2;j<=i;j++)
                    if(i%j==0){
                        
                        //nの因数iが素数かどうかを判定する
                        //割り切れたら素数じゃないのでループ抜ける
                        
                        break;

            }
                    //jが最終まで行けばiが素数なのでans++
                    if(j==i)ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include<iostream>

using namespace std;

int n;
int a[1000000];
int ans;

int main()
{
    while(cin >> n)
    {
        for(int i = 2; i <= n; i++)
        {
            if(i == 2 || i == 3 || i == 5 || i == 7)ans++;
            if(i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0)ans++;
        }
        cout << ans << endl;
        ans = 0;
    }
    return 0;
}

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

bool isPrime(int);

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

bool isPrime(int x) {
	if (x % 2 == 0)
		return true;
	for (int j = 3; j * j <= x; j += 2) {
		if (x % j == 0)
			return false;
	}
	return true;
}

C++: #include<memory.h>
#include<cstdio>
const int maxn=100000;
int x;
bool isPrime[maxn];
void generateprime()
{

    memset(isPrime,true,sizeof(isPrime));
    for(int i=2;i<maxn;i++)
        for(int j=2;j*i<maxn;j++)
        isPrime[j*i]=false;
}

int main()
{
    generateprime();
    while(scanf(" %d",&x)!=EOF)
    {   int res=0;
        for(int i=2;i<=x;i++)
            if(isPrime[i])
            {
            res=res+1;}
        printf("%d\n",res);
    }
}

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

bool isPrime(unsigned int n) {
  unsigned int count=0;
  unsigned int max;
  count = 0;
  max = n;

  for(int i=2; i<max; i++) {
    if(n%i==0) return false;
    max = n/i;
  }
  return true;
}

int main() {
  unsigned int input;
  unsigned int count;
  unsigned int cum[500000]; // for odd numbers greater than or equal to 1

  count = 1; // For 2
  cum[0] = 0; // For 1
  cum[1] = 2; // For 3
  for(int i= 2; i<500000; i++) {
    if(isPrime(2*i+1)) {
      cum[i] = cum[i-1]+1;
      count++;
    } else {
      cum[i]=cum[i-1];
    }
  }

  while(cin >> input) {
    count = 0;
    if(input==2)
      cout << "1" << endl;
    else
      cout << cum[(int)(input-0.5)/2] << endl;
  }

  return 0;
}

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

using namespace std;

vector<int>soe(int n);

int main(void)
{
	int num, pn;
	int count = 0;
	
	while(cin >> num){
		vector<int>test(num);
		test = soe(num);
		
		for(int i = 0; i < num; i++){
			if(test[i])
			count++;
		}
		cout << count <<endl;
	}
	return 0;
}

vector<int>soe(int n){
	vector<int>hyo(n);
	for(int i = 2; i < n; i++)
	hyo[i] = i;
	for(int i = 2; i*i < n; i++){
		if(hyo[i])
		for(int j = i*i; j < n; j += i){
			hyo[j] = 0;
		}
	}
	return hyo;
}

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

using namespace std;

typedef long long ll;

int main()
{
    int prime_num[1000001];
    memset(prime_num, 0, 1000001);
    prime_num[2] = 1;
    int ans = 1;
    for(int i = 3; i <= 1000000; i++) {
        if(i % 2 == 0) { 
            prime_num[i] = prime_num[i-1];
            continue;
        }
        bool is_prime = true;
        for(int j = 3; j*j <= i; j++) {
            if(i % j == 0) {
                is_prime = false;
                break;
            }
        }
        if(is_prime) {
            prime_num[i] = prime_num[i-1] + 1;
        } else {
            prime_num[i] = prime_num[i-1];
        }
    }
    int n;
    while(cin >> n) {
        cout << prime_num[n] << endl;
    }
    return 0;
}