Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

C++: #include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
bool hurui[1000000];
int main(){
    int n;
    while(scanf("%d",&n) != EOF){
        for(int i = 0;i <= n;i++)
            hurui[i] = true;

        for(int i = 2;i <= (int)sqrt(n);i++) {
            if(!hurui[i])
                continue;
            int m = i * 2;
            while(m <= n) {
                hurui[m] = false;
                m += i;
            }
        }
        int cou = 0;
        for(int i = 2;i <= n;i++) {
            if(hurui[i]) {
                cou++;
            }
        }
        printf("%d\n",cou);
    }
    return 0;
}

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

const int MAX = 1000000;
bool prime[MAX] = { true };
int pcount[MAX];

int main(){
	int n;
	prime[0] = prime[1] = false;
	for(int i = 2;i < MAX;++i) prime[i] = true;
	for(int i = 2;i <= sqrt(MAX);++i){
		if(prime[i]){
			for(int j = i + i;j < MAX;j += i){
				prime[j] = false;
			}
		}
	}
	pcount[0] = 0;
	for(int i = 1;i < MAX;++i){
		pcount[i] = pcount[i - 1];
		if(prime[i]) pcount[i]++;
	}
	while(cin >> n){
		cout << pcount[n] << endl;
	}
	return 0;
}

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

int is_prime_f(int n) {
    int i;
    if(n < 2)
        return -1;
    else if(n == 2)
        return 1;

    if(n % 2 == 0)
        return -1;

    for(i = 3; i <= n / i; i += 2)
        if(n % i == 0)
            return -1;
    return 1;
}

unordered_map<int, int> map;

bool is_prime_map(int n) {
    int is_prime = map[n];
    if (is_prime == 0) {
        is_prime = is_prime_f(n);
        map[n] = is_prime;
    }
    return is_prime == 1;
}

int prime_num_count(int max) {
    int count = 0;
    for (int i = 1; i <= max; ++i) {
        if (is_prime_map(i)) {
            count++;
        }
    }
    return count;
}

int main() {
    string str;
    while(getline(cin, str)) {
        cout << prime_num_count(stoi(str.c_str())) << endl;
    }
    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[30];
  int i = 0, max_num;
  while (std::cin >> ns[i]) {
    max_num = std::max(max_num, ns[i]);;
    if (ns[i] % 2 == 0)
      ns[i] --;
    i ++;
  }
  get_prime(max_num);
  for (int j = 0; j < i; j ++) {
    std::cout << prime[ns[j]] << std::endl;
  }
  return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;


int main(){

	int i, j, k;
	int n;

	while(cin >> n){

		int count = 0;

		if(n>2){
			count ++;
			for(i=3 ; i<=n ; i+=2){
				for(j=3 ; j<=(int)sqrt(i) ; j+=2){
					k = i % j;
					if(k == 0) break;
				}
				if(j > (int)sqrt(i)) count ++;
			}
		}
		cout << count << endl;

	}


	return 0;
}

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

int main() {
	vector<bool>hantei(1000000, true);
	vector<int>sosuu(1000000);
	int s = 0;
	for (int a = 2; a < 1000000; a++) {
		if (hantei[a]) {
			s++;
			for (int b = a * 2; b < 1000000; b += a)hantei[b] = false;
		}
		sosuu[a] = s;
	}
	int c;
	while (cin >> c, c) {
		cout << sosuu[c] << endl;
	}
}

C++: #include<iostream>

int main(){

	bool data[100001];

	for (int i = 0; i < 100001; i++)
		data[i] = true;

	int in;

	int res=0;

	for(int i=2;i<=100000;i++){
		for (int j = 2; j < i; j++) {
			if (i%j == 0){
				data[i] = false;
				goto fl;
		}
	}
	fl:;
	}

	while (true) {

		std::cin >> in;

		for (int i = 2; i <= in; i++) {
			if (data[i] == true)
				res++;
		}

		std::cout << res << std::endl;

	}

		return 0;
}

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

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;

inline int Sieve_of_Eratothenes(const int n) {

	std::vector<bool> flg(n + 1, true);
	for (int i = 2; i < n; i++) {
		if (flg[i]) {
			for (int j = i + i; j <= n; j += i) {
				flg[j] = false;
			}
		}
	}

	return(std::count(flg.begin(), flg.end(), true) - 2);

}

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int a = 0;
	std::vector<int> A;
	while (std::cin >> a) {
		A.push_back(a);
	}

	std::for_each(A.begin(), A.end(),
		[](int i) {std::cout << Sieve_of_Eratothenes(i) << std::endl; });
}

C++: #include<stdio.h>
#include<math.h>
int judge(int x)
{
	for (int i = 3; i < sqrt(x) + 1; i++)
		if (x%i == 0)
			return 0;
	return 1;
}
int main()
{
	int a, num;
	while (scanf("%d", &a) != EOF)
	{
		num = 1;
		if (a < 2)
			num = 0;
		for (int i = 3; i <= a; i+=2)
			if (judge(i))
				num++;
		printf("%d\n", num);
	}
	return 0;
}

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

void AOJ0009()
{
	int n = 0;
	int prime[100000];
	int count = 0;
	for (int i = 2; i <= 100000; i++)
	{
		int j = 2;
		bool flag = false;
		for (j = 2; j <= i; j++)
		{
			if (i % j == 0)
				break;
		}
		if (i == j)
		{
			prime[count] = i;
			count++;
		}
	}

	while (cin >> n)
	{
		count = 0;
		while (prime[count] <= n)
		{
			count++;
		}
		cout << count << endl;
	}
}
int main()
{
	//AOJ0005();
	//AOJ0007();
	AOJ0009();
	return 0;
}

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

using namespace std;

int isprime(int x){
	int i;
	if(x == 2 || x == 3) return 1;
	else if(x % 2 == 0) return 0;
	else{
		for(i = 3; i <= sqrt(x); i += 2){
			if(x % i == 0) return 0;
		}
		return 1;
	}
}

int main(){
	int n, i, count;
	while(cin >> n){
		count = 0;
		for(i = 2; i <= n; i++){
			if(i % 2 == 0 && isprime(i) == 1) count++;
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cmath>
#define FOR(x,s,g) for(int x=(s);x<=(g);x++)
using namespace std;

int main(){
  int n;
  while(cin>>n){
    int count=0;
    FOR(i,2,n){
      int e=sqrt(i);
      FOR(j,2,e){
	if(i%j==0){
	  goto end;
	}
      }
      count++; 
    end:
      ;
    }
    cout<<count<<endl;
  }
  return 0;
}