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 <stdio.h>

const int MAX_V = 1000000;

int p[MAX_V+1];
int data[MAX_V];
int main() {
    int i,k,a;
    for(i = 2;i<=MAX_V;i++) {
        p[i] = 1;
    }
    for(i = 2;i*i<=MAX_V;i++) {
        if(p[i]) {
            for(k = 2*i;k<=MAX_V;k+=i) {
                p[k] = 0;
            }
        }
    }
    for(i = 0;i<=MAX_V;i++){
        data[i+1] = data[i]+p[i];
    }
    while(scanf("%d",&a) != EOF){
        printf("%d\n", data[a + 1]);
    }
    return  0;
}

C++: #include<iostream>
#include<cstring>
#include<math.h>
using namespace std;
const int MAX = 1000000;
int prime(int n)
{
	int ans = 0;
	bool prime[MAX];
	memset(prime, 0, sizeof(prime));
	for (int i = 2; i < n;i++)  
	{ 
		for (int j = 2; j <= n / i; j++)
		{
			if (i*j <= n)
				prime[i*j] = 1;
		}
	}
	for (int i = 2; i <= n; i++)
	{
		if (!prime[i])
			ans++;
	}
	return ans;
}
int main()
{
	int n, m = 0;
	while (cin >> n&&m<30)
	{
		cout << prime(n) << endl;
		m++;
	}
	return 0;
}

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

int arr[1000000];

void ar()
{
	int cnt;
	arr[2] = 1;
	int j;
	int i = 3;
	for (; i < 100000; ++i) {
		cnt = 1;
		for (j = 2; j < i; ++j) {
			if (i%j == 0) {
				arr[i] = arr[i - 1];
				--cnt;
				break;
			}
		}
		arr[i] = arr[i - 1] + cnt;
	}
}

int main()
{
	int x;
	ar();
	while (cin >> x) {
		cout << arr[x] << endl;
	}
	return 0;
}

C++: #include <stdio.h>
int main()
{
int n,i,j;
int ans;
char era[1000000];
while(scanf("%d",&n) != EOF){
for(i=0; i<=n;i++)
era[i]=1;
ans=0;
for(i=2;i<=n;i++){
if(era[i] == 1){
ans++;
for(j=i; j<=n;j+=i)
era[j]=0;
}
}
printf("%d\n",ans);
}
return 0;
}

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

int prime[1000000];


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


void get_prime(int max_num) {
  int primecount = 1;
  prime[2] = primecount;
  for (int i = 3; i <= max_num; i += 2) {
    if (isPrime(i))
      prime[i] = ++primecount;
    else
      prime[i] = primecount;
  }
}


int main () {
  int ns[31];
  int i = 0, max_num;
 
  return 0;
}

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

using namespace std;

// エラトステネスの篩 : [0, n] の素数表を返す
// 計算時間 O(n log log n), 領域 O(n)
vector<bool> SieveOfEratosthenes(const int n) {
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = is_prime[1] = false;

    for (int i = 2; i * i <= n; ++i)
        if (is_prime[i])
            for (int j = i * i; j <= n; j += i)
                is_prime[j] = false;

    return is_prime;
}

// i \in [0, n] 以下の素数の数を求める
// 計算時間 O(n log log n), 領域 O(n)
vector<int> CountPrime(const int n) {
    vector<bool> is_prime = SieveOfEratosthenes(n);
    vector<int> count(n + 1);

    for (int i = 2; i <= n; ++i)
        count[i] += count[i - 1] + is_prime[i];

    return count;
}


int main() {
    cin.tie(0); ios::sync_with_stdio(false);

    auto cnt_prime = CountPrime(999999);
    int n;
    while (cin >> n)
        cout << cnt_prime[n] << '\n';

    return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
    int a,f,counter;
    while(cin>>a)
    {
        counter=1;
        for(int i=3;i<=a;i++)
        {
            f=0;
            for(int j=2;j<i;j++)
            {
                if(i%j==0)
                {
                    f=1;
                    break;
                }
            }
            if(f==0)
                counter++;
        }
        cout<<counter<<endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int n;
	int ans[100000];
	int count = 0;
	int ans_count = 0;
	while (cin >> n) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (i%j == 0 && j != 1 && j != i)
				{
					count++;
				}
			}
			if (count == 0) {
				ans_count++;
			}

			count = 0;

		}
		cout << ans_count - 1 << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n, cnt;		
	while(cin >> n){
		//??????????????????1???????????\??±??????
		bool prime[n+1] = {false};
		prime[1] = true;
		// ??¨??????????????????????????????
		for(int j = 2; j*j <= n; j++){
			if(!prime[j]){
				for(int k = j; k*j <= n; k++){
					prime[j*k] = true;
				}
			}
		}
		cnt = 0;
		//false?????¨????´???°
		for(int i = 1; i <= n; i++){
			if(!prime[i]) cnt++;
		}
		cout << cnt << endl;
	}
}

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

using namespace std;

int main() {
  const int N_MAX = 1000000;
  int table[N_MAX];

  for (int i = 0; i < N_MAX; i++) {
    table[i] = 0;
  }
  table[0] = table[1] = 1;
  int sq = sqrt(N_MAX);
  for (int i = 2; i < sq+1; i++) {
    if (table[i] == 0) {
      for (int j = i*2; j < N_MAX; j += i) {
        table[j] = 1;
      }
    }
  }
  int n;
  while (cin >> n) {

    int ans = 0;
    for (int i = 0; i <= n; i++) {
      if (table[i] == 0) ans++;
    }
    cout << ans << endl;

  }

  return 0;
}

C++: 

#include<iostream>
#include<math.h>
main(){
	int i,j,n,p[1000000];
	std::cin>>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];
	std::cout<<j<<std::endl;
}

C++: int main(){
	int i , j , n , pn , cn=0;
	
	while(cin>>n){
		pn=1;
		for(i=3 ; i<=n ; i++){
			for (j=2 ; j<i ; j++){
				if (i%j==0) goto skip;
			}
			pn++;
			skip:;
		}
		if(n==0 || n==1 ) {
			cout << 0 << endl;
		} else {
			cout << pn << endl;
		}
		cn++;
		if(cn>=30) break;
	}
	return 0;
}

C++: #include<iostream>
bool prime(int n){
	for(int i=1;i<n/2;i++){
		if(n%i==0)return false;
	}
	return true;
}
int main(){
	int n;
	while(std::cin>>n){
		int a=0;
		for(int i=1;i<=n;i++){
			if(prime(i))a++;
		}
		std::cout<<a<<std::endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
// have you mooed today?
bool isprime(int& num)
{
    static int c;
    static int max;
    max = sqrt(num) + 2;
    if(num == 2) return true;

    for(c=2; c < max; c++)
        if(num % c ==0) return false;
    return true;
}

main()
{
    int ans;
    int buff;
    while(cin >> buff)
    {
        ans  = 0;
        for(int d =2; d <= buff; d++)
        {
            if(isprime(d)) ans++;
        }
        cout << ans << endl;
    }
}

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

#define Max 1000000

int isPrime[Max];

int main(){
    int num;
    int i;

    isPrime[0] = isPrime[1] = 0;
    for(i = 2; i < Max; ++i){
        isPrime[i] = 1;
    }
    
    for(i = 3; i < Max; ++i){
        if(i % 2 == 0){
            isPrime[i] = 0;
        }
    }

    for(i = 4; i < Max; ++i){
        if(i % 3 == 0){
            isPrime[i] = 0;
        }
    }

    for(i = 6; i < Max; ++i){
        if(i % 5 == 0){
            isPrime[i] = 0;
        }
    }

    for(i = 8; i < Max; ++i){
        if(i % 7 == 0){
            isPrime[i] = 0;
        }
    }

    while(cin >> num){
        int count = 0;
        for(i = 0; i <= num; ++i){
            if(isPrime[i] == 1){
                count++;
            }
        }
        cout << count << endl;
    }
}