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

int main(){
	bool is_prime[1000000];

	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 n_prime[1000000];

	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 <stdio.h>
int isprime(int n){
  for(int i = 2; i * i <= n; i++){
    if(n % i == 0)return 0 ;
  }
  return 1;
}
int main(){
  int n;
  while(1){
    scanf("%d",&n);
    if(n == 0)break;
    for(int i = n; i > 3; i--){
      if(isprime(i) == 1 && isprime(i-2) == 1){
        printf("%d %d\n",i-2,i);
        break;
      }
    }
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int n;
bool is_prime[1000000];
int prime[1000000];

int main(int argc, char const* argv[])
{
	fill(is_prime, is_prime+1000000, true);
	is_prime[0] = false;
	is_prime[1] = false;
	int res = 0;
	for(int i = 2; i < 1000000; i++){
			if(is_prime[i]){
					res++;
					for(int j = 2; j * i < 1000000; j++){
							is_prime[j * i] = false;
					}
			}
			prime[i] = res;
	}
	while(cin >> n){
			cout << prime[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	bool prime[1000000];
	rep(i,1000000)prime[i]=true;
	prime[0]=prime[1]=false;
	loop(i,2,1000){
		for(int j=i*2;j<1000000;j+=i){
			prime[j]=false;
		}
	}
	int n;
	while(cin>>n){
		int cnt=0;
		rep(i,n+1){
			if(prime[i])cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

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

int main(void) {
  int table[MAX_NUM + 1] = {0};
  for(int i = 2; i < MAX_NUM; i++) {
    for(int j = i * 2; j < MAX_NUM; j = j + i) {
      table[j] = 1;
    }
  }

  int num;
  int ans = 0;
  while(cin >> num) {
    for(int i = 2; i <= num; i++) {
      if(table[i] == 0) {
        ans++;
      }
    }
    cout << ans << endl;
    ans = 0;
  }

  return 0;
}

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

int get_num_of_under_n(int n) {
	bool* numbers = new bool[n + 1];
	for (int i = 2; i < n + 1; i++) {
		numbers[i] = true;
	}
	for (int i = 2; i < sqrt(n); i++) {
		if (numbers[i] == true) {
			for (int j = 0; i*(j + 2) <= n; j++) {
				numbers[i*(j + 2)] = false;
			}
		}
	}
	int ans = 0;
	for (int i = 2; i < n + 1; i++) {
		if (numbers[i] == true)ans++;
	}
	return ans;
}
int main() {
	int n;
	while (cin>>n) {
		cout << get_num_of_under_n(n)<<endl;
	}
}

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

using namespace std;

typedef unsigned int U;

const U R = 1000000;
bool isp[R];
vector<U> primes;

void elatos(){
  memset(isp , 1 , sizeof(isp));
  U n = 0;
  for(U i=2; i < R; i++)
    if(isp[i])
      for(U j=2*i; j < R; j+=i) isp[j] = 0;
  for(U i=2; i<R; i++) if(isp[i]) primes.push_back(i);
}

int main(){
  elatos();
  int n;
  while(cin >> n){
    vector<U>::iterator it = lower_bound(primes.begin(), primes.end() , n);
    cout << it - primes.begin() << 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));


	for (int i = 2; 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 = 2; i <= MAX; i++){
		if (prime[i]){
			sum++;
		}
		amount[i] = sum;
	}

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

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

int prime(int n) {
	int k;
	if(n == 2) return 1;
	if(n % 2 == 0) return 0;
	for(k = 3; k * k <= n; k += 2) {
		if(n % k == 0) return 0;
	}
	return 1;
}

int cntPrime(int n) {
	int cnt = 0, i, k;
	for(i = 2; i <= n; i++) {
		cnt += prime(i);
	}
	return cnt;
}

int main() {
	int a;
	int arg[1024] = { 0 };
	int cnt = 0;
	while(scanf("%d", &a) != EOF) {
		printf("%d\n", cntPrime(a));
	}
	int i;
	for(i = 0; i < cnt; i++) {
	}
}

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

#define ll long long int

#define rep(p,q) for(int i = p; i < q;i++)


void eratos(bool isPrime[10000000]) {
	
	rep(0, 10000000)isPrime[i] = true;
	rep(2, 10000000) {
		if (!isPrime[i])continue;
		else {
			for (int j = i * 2; j < 10000000; j += i) {
				isPrime[j] = false;
			}
		}
	}
}

//9

int main(void) {
	static bool isPrime[10000000];
	eratos(isPrime);
	static int countPrime[10000000];
	countPrime[0] = 0;
	countPrime[1] = 0;
	rep(2, 10000000) {
		if (isPrime[i])countPrime[i] = countPrime[i - 1] + 1;
		else countPrime[i] = countPrime[i - 1];
	}
	int n;
	while (cin >> n) {
		cout << countPrime[n] << endl;
	}

}

C++: int main() {
	bool isPrime[1000000] = {true};

	for (int i = 0; i < 1000000; i++) {
		isPrime[i] = true;
	}

	isPrime[1] = false;
	for (int i = 2; i < 1000000; i++) {
		if (!isPrime[i])
			continue;

		if (isPrime[i]) {
			int k = 2*i;
			while (k < 1000000) {
				isPrime[k] = false;
				k += i;
			}
		}
	}

	int n;
	while (cin >> n) {
		int sum = 0;
		for (int i = 2; i <= n; i++) {
			if (isPrime[i])
				sum++;
		}
		cout << sum << endl;
	}

	return 0;
}

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

bool prime(int a) {
	for (int b = 3;; b += 2) {
		if (a%b == 0)return false;
		if ((b + 1)*(b + 1) > a)return true;
	}
}
int main() {
	while (1) {
		int s = 0;
		int a;
		cin >> a;
		if (cin.fail())break;
		if (a > 1)s++;
		if (a > 2)s++;
		for (int b = 5; b <= a; b+=2) {
			if (prime(b))s++;
		}
		cout << s << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main() {
	int n, count = 0;
	while(cin >> n) {
		for(int i = 2; i <= n; i++) {
			for(int j = 2; j < i; j++) {
				if(i % j == 0) {
					count--;
					break;
				}
			}
		}
		cout << count << endl;
		count = 0;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

bool flag[10000001];

int main(){
	int n = 0, ans = 0;
	
	for (int i = 0; i <= 1000000; i++){
		if (i <= 1) flag[i] = false;
		else flag[i] = true;
	}
	for (int i = 2; i <= 1001; i++){
		if(flag[i] == true){
			for(int j = i * 2; j <= 1000000; j += i){
				flag[j] = false;
			}
		}
	}
	while(cin >> n){
		ans = 0;
		for(int i = 0; i <= n; i++){
			if(flag[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
 }