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<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	int n;
	int count = 1;
	cin >> n;
	if (n == 1) {
		cout << 0 << endl;
	}
	else if (n == 2) {
		cout << 1 << endl;
	}
	else {
		for (int t = 3; t <= n; t += 2) {
			FOR(i, 2, t - 1) {
				if (t%i == 0) {
					break;
				}
				if (i == t - 1) {
					count++;
					break;
				}
			}
		}
		cout << count << endl;
	}
	
	return 0;
}

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

int main(){
int n;
cin >> n;
int a[n+1];
int b;
int c;
b=1;
while(b<n+1){
a[b]=0;
b=b+1;}
a[1]=1;
b=2;
while(b<n+1){
if(a[b]=0){ c=2; while(1){if(c*b>n){break;} a[c*b]=1; c=c+1;}}
b=b+1;}

int d;
d=0;
b=1;
while(b<n+1){
if(a[b]=0){d=d+1;}
b=b+1;}
cout << d;


}

C++: 
/* vo00_09.cpp */

#include <iostream>
using namespace std;

const int N = 1000000;
int prime[N];

void init();

int main()
{
	init();

	int n;
	while (cin >> n) {
		
		cout << prime[n] << '\n';

	}

	return 0;
}

void init()
{
	prime[0] = prime[1] = -1;

	int count = 0;
	for (int i = 2; i < N; ++i) {
		if (prime[i] == 0) {
			for (int j = i * 2; j < N; j += i) { prime[j] = -1; }
			count++;
		}
		
		prime[i] = count;
	}
}

C++: #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())


int mem[1000000];
int ans[1000000];

int main(int argc, char const *argv[])
{
	int max_num = 1000000;
	int loop_max = sqrt(1000000);
	memset(mem, 0, 1000000);
	for (int i = 2; i < loop_max; i++)
	{
		int c = i * 2;
		while(c < max_num)
		{
			mem[c] = 1;
			c+= i;
		}
	}
	int n;
	int sum = 0;
	ans[0] = ans[1] = 0;
	for (int i = 2; i < max_num; i++)
	{
		sum += mem[i] ? 0 : 1;
		ans[i] = sum;
	}
	while(scanf("%d", &n) != EOF)
	{
		printf("%d\n", ans[n]);
	}
	return 0;
}

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

using namespace std;

int main(){
	int n,i,j,buf,cnt;

	scanf("%d",&n);

	while(n != EOF){
		cnt = 1;

		for(i=3;i<=n;i+=2){
			buf = (int)sqrt((double)i);

			for(j=3;j<=buf;j+=2){
				if((i % j) == 0){
					cnt--;
					break;
				}
			}

			cnt++;
		}

		printf("%d\n",cnt);

		scanf("%d",&n);
	}

	return 0;
}

C++: //============================================================================
// Name        : desk.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<stdio.h>
#include<iostream>
using namespace std;
int main(){

 int n=0,f=0,P=0;

 while(scanf("%d",&n)!=EOF){

 for(int i=2;i<n;i++){

	 if(n%i==0){
		f=1;
		}

 }

 if(f==0){
	 P++;
 }
 cout<<P<<endl;
 }

  return 0;
}

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

int main(){
	int n,t;
	while(scanf("%d",&n)!=EOF){
		int c=1;
		for(int i=3;i<=n;i+=2){
			int j=3;
			t=1;
			while( j <= sqrt(i) ){
				if(i%j==0){
					t=0;
				}
				j+=2;
			}
			if(t){
				c++;
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

C++: #include<cstdio>
#include<cstring>
using namespace std;
const int MAXN=1e7;
int is_prime[MAXN],prime[10000];
int sieve(int n){
	memset(is_prime,-1,sizeof(is_prime));
	int index=0;
	prime[0]=prime[1]=0;
	for(int i=2;i<=n;i++){
		if(is_prime[i])prime[index++]=i;
		for(int j=2*i;j<=n;j+=i)
		is_prime[j]=0;
	}
	return index;
}
int main(void){
	int n;
	while(scanf("%d",&n)!=EOF){
		printf("%d\n",sieve(n));
	}
	return 0;
}

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

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

int main(int argc, char** argv){
	
	int search, counter;
	
	while((scanf("%d", &search)) != EOF){
		counter = 0;
		for(int i = 2; i <= search; i++){
			counter += isPrimeNumber(i) ? 1 : 0;		
		}
		printf("%d\n", counter);
	}
	
	return 0;
}

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

#define MAX_SIZE (1000000)

int prime[MAX_SIZE];

int main()
{
	int n;

	prime[0] = prime[1] = 0;

	for (int i = 2; i < MAX_SIZE; i++){
		prime[i] = 1;
	}

	for (int i = 0; i < MAX_SIZE; i++){
		for (int j = i * i; j < MAX_SIZE; j += i){
			prime[j] = 0;
		}
	}

	for (int i = 1; i < MAX_SIZE; i++){
		prime[i - 1] += prime[i];
	}

	while (scanf("%d", &n) != EOF){
		printf("%d\n", prime[n]);
	}

	return (0);
}

C++: #include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;

int main(void) {
	int n;
	int count = 0;

	while (cin >> n) {
		count = 0;
		if (n >= 2) {
			count++;
		}
		FOR(i, 3, n) {
			FOR(t, 2, i - 1) {
				if (i%t == 0) {
					break;
				}
				if (t == i - 1) {
					count++;
				}
			}
		}
		cout << count << endl;
		
	}
	
	return 0;
}

C++: #include <stdio.h>

int IsPrime(int n);

int main(void){
    int n, cnt, minID, min=1;
    int max[30], sol[30], listID=0;
	
    while (scanf("%d", &n) && n!=EOF){
        cnt=0;
        min = 1;
        minID = 0;
        for (int i=0; i<listID; i++){
            if (max[i] < n && min <max[i]){
                min = max[i];
				cnt = sol[i];
            }
        }
        for (int i=min+1; i<=n; i++){
            if (IsPrime(i)) cnt++;
        }
        max[listID] = n;
        sol[listID] = cnt;
        listID++;
        printf("%d\n", cnt);
    }
    return 0;
}

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

C++: #include <cmath>
#include <cstdio>
#include <map>
 
inline bool fermat_test(int n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else {
        return (static_cast<int>(std::pow(2, n - 1)) % n) == 1;
    }
}
 
inline bool prime_test(int n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else {
        for (int i = 3; i < static_cast<int>(std::sqrt(n)); i += 2) {
            if ((n %= i) == 0) {
                return false;
            }
        }
    }
    return true;
}

int m[999999];

int main() {
    m[3] = 2;
    int n;
    while (~scanf("%d", &n)) {
        if (n == 2) {
            printf("1\n");
            continue;
        }
        for (int i = 5; i <= n; i += 2) {
            if (m[i] > 0)
                continue;
 
            m[i] = m[i - 2] + (fermat_test(i) && prime_test(i));
        }
        printf("%d\n", m[n % 2 == 0 ? n - 1 : n]);
    }
}