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>
#include <stdlib.h>
#include <math.h>
int main()
{
    int i,j,flag,n,c=0;
    while(scanf("%d",&n)==1)
    {
        for(i=2;i<=n;i++)
        {
            flag=0;
            for(j=2;j<=sqrt(i);j++)
            {
                if(i%j==0)
                {
                    flag=1;
                }
            }
            if(flag==0)
            {
                c++;
            }
        }
        printf("%d\n",c);
        c=0;
    }
    return 0;
}

C++: #include <stdio.h>
const int MAX_V = 999999;
int main(){
int prime[MAX_V+1]={0};
int sum[MAX_V+2]={0};
int i, k, v ,n;
  for(i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++) {
    if(prime[i]) {
      for(k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }
  for(i=0 ;i<=MAX_V+1 ;i++){
    sum[i+1] += sum[i] + prime[i];
  }

  while(scanf("%d" ,&n)!=EOF){
     printf("%d\n" ,sum[n+1]);
  }
  return 0;
}

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

bool prime[1000001];

void era(){
	for(int i=2;i<1000000;i++)prime[i]=true;
	for(int i=2;i*i<1000000;i++){
		if(prime[i]==true){
			for(int j=i*2;j<1000000;j+=i){
				prime[j]=0;
			}
		}
	}
}

int main(){
	era();
	int n,ans;
	while(cin>>n){
		ans=0;
		for(int i=0;i<=n;i++){
			if(prime[i]==1)ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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 = upper_bound(primes.begin(), primes.end() , n);
    cout << it - primes.begin() << endl;
  }
  return 0;
}

C++: #include<stdio.h>


int main(){
	int n;
	bool data[1000000];

	int i,j;
	data[0]=data[1]=0;
	for(i=2;i<1000000;i++){
		data[i]=1;
	}

	for(i=0;i*i<1000000;i++){
		if(data[i]==1){
			for(j=i+i;j<1000000;j=j+i){
				data[j]=0;
			}
		}
	}


	while(scanf("%d",&n)!=EOF){
		j=0;
		for(i=0;i<n;i++){
			if(data[i]==1)j++;
		}
		printf("%d\n",j);
	
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#ifndef typeof
#define typeof __typeof__
#endif // typeof

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(typeof((c).rbegin()) i = (c).rbegin(); i != (c).rend(); i++)
#define repby(i, a, b, step) for(typeof(b) i = (a); i < (b); i += (step))
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

vector<bool> prime_table;
vi nprimes;

void mkprime_table(int n) {
  prime_table = vector<bool>(n+1, true);
  nprimes = vi(n+1, 0);
  prime_table[0] = prime_table[1] = false;
  for (int i = 4; i <= n; i += 2) {
    prime_table[i] = false;
  }

  for (int i = 3; i*i <= n; i += 2) {
    if (prime_table[i]) {
      for (int j = 2; i*j <= n; j++) {
        prime_table[i*j] = false;
      }
    }
  }

  int total = 0;
  for (int i = 0; i <= n; i++) {
    if (prime_table[i]) {
      total++;
    }
    nprimes[i] = total;
  }
}

int main(int argc, char **argv)
{
  vi v;
  int n;

  while (cin >> n) {
    v.pb(n);
  }

  mkprime_table(*max_element(all(v)));

  tr(v, i) {
    cout << nprimes[*i] << endl;
  }

  return 0;
}

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

int main(){
  int input;
  scanf("%d",&input);
  int count = 1;
  for(int i = 3;i <= input;i += 2){
    bool isPrime = false;
    for(int s = 3;s <= sqrt((float)i);s += 2){
      if(i % s == 0){isPrime = true; break;}
    }
    if(!isPrime)count++;
  }
  printf("%d\n",count);


  return 0;
}

C++: #include<iostream>

using namespace std;
bool prime(int x){
	if(x==2)return true;
	if(x==3)return true;
	for(int i=2;i*i<=x;i++){
		if(x%i==0)return false;
	}
	return true;
}
int main(){
	int data[1000000];
	data[0]=0,data[1]=0;
	for(int i=2;i<1000000;i++){
		if(prime(i))data[i]=data[i-1]+1;
		else data[i]=data[i-1];
	}
	int n;
	while(cin>>n)cout<<data[n]<<endl;
}

C++: #include<cstdio>
#include<string.h>

using namespace std;

int main(){
	static bool p[1000000];
	memset(p,true,sizeof(p));
	p[0] = false;
	p[1] = false;
	for(int i= 2;i<1000000;i++){
		if(p[i]){
			for(int j=i*2;j<1000000;j+=i){
				p[j] = false;
			}
		}
	}
	int n,ans;
	while(!(scanf("%d",&n)==EOF)){
		ans=0;
		for(int j=2;j<=n;j++){
			if(p[j])ans++;
		}
		printf("%d\n",ans);
	}
}

C++: /*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

int main() {
	int a;
	int count;
	int ccount;
	vector<int> c = { 0 };
	while (cin >> a)
	{
		a = a + 1;
		count = 0;
		/*
		// ?´???°?????????
		// ??????????????°
		for (size_t i = 2; i < a; i++)
		{
			ccount = 0;
			// ????????°
			for (size_t j = 1; j <= i; j++)
			{
				//cout << "i= " << i << "j= " << j << endl;
				if (i % j == 0) {
					ccount++;
				}
			}
			if (ccount > 2) {
				count++;
			}
		}*/
		// ?????§????????§????????????0??§???????????????
		c.resize(a);

		
		// 2*i????????§????????§?????????????????????1?????????
		for (size_t i = 2; i < a; i++)
		{
			for (size_t j = 2; i*j < a; j++)
			{
				//cout << i*j << endl;
				c[i*j] = 1;
			}
		}
		// ??????????????????0??????????????°????????????
		for (size_t i = 0; i < a; i++)
		{
			if (c[i] == 0) {
				count++;
			}
		}
		cout << count-2 << endl;

		// ?¢??????¨
		
		for (size_t i = 0; i < a; i++)
		{
			cout << i << " = " << c[i] << endl;
		}
		
	}
	return 0;
}