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

int main()
{
	
	long long int k,p[100000];
	long long int bn,n=-1;
	p[0]=2;
	while(1){
		bn=n;
		cin>>n;
		if(n==bn)
			return 0;
	k=1;
	int r=(int)sqrt((float)n);
	//ツ確ツ認ツ用ツ素ツ青板づ債閉つ篠づ個づ慊づ必ツ要
	//ツ閉つ篠づ慊づづ慊づュツつキ
	for(int i=3;i<r;i++){
		//ツつサツづェツづ慊づづ個素ツ青板づ確ツ認
		for(int j=0;j<k;j++){
			//ツ催甘コツづ慊づ環づェツづ按つゥツづつスツづァツカツウツδ督トツつオツづ、ツ確ツ認ツ用ツ素ツ青板づ個配ツ療アツづ可格ツ納
			if(i%p[j]==0){
				break;
			}else if(j==(k-1)){
				p[k]=i;
				k++;
			}
		}
	}
	long long int r_k=k;
	for(;r<=n;r++){
		for(long int i=0;i<r_k;i++){
			if(r%p[i]==0){
				break;
			}else if(i==r_k-1){
				k++;
			}
		}
	}
	if(n==1){
		k=0;
		cout<<k<<endl;
	}else if(n==2){
		k=1;
		cout<<k<<endl;
	}else if(n==3){
		k=2;
		cout<<k<<endl;
	}else{
	cout<<k<<endl;
	}
	}
}

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

using namespace std;

vector<int> ps;

int isprime(int n){
	vector<int>::iterator it;
	for(it=ps.begin();it!=ps.end();it++){
		if(n%(*it) == 0) return 0;
		if(n <= (*it)*(*it)) break;
	}
	ps.push_back(n);
	return 1;
}

int main(){
	int n;
	ps.push_back(2);
	while(scanf("%d", &n)!=EOF){

		int c=0;
		int last=2;
		for(vector<int>::iterator it=ps.begin();it!=ps.end();it++){
			if((last = *it) <= n) c++;
		}

		for(int i=last+1;i<=n;i++){
			if(i&1 && isprime(i)) c++;
		}

		printf("%d\n", c);
	}
}

C++: #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define N 999999L
bool num[N];

void furui(){
  long int i;
  int divide;
  int rt = (int) sqrt(N);
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(void){
  int c, i, j;
  long int k;
  char buf[7];
  long int n;
  long int count;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0; ;i++){
      c = getchar();
      if(c == EOF || c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == 1) count++;
    }
    std::cout << count << '\n';
    if(c == EOF) break;
  }
  return 0;
}

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

using namespace std;

bool p[10000000];
vector<int> prime;

void init(){
    memset(p,1,sizeof(p));
    p[0] = p[1] = false;
    for(int i = 2; i <= 1000000; i++){
        if(!p[i]) continue;
        for(long long j = 1LL*i*i; j <= 1000000; j += i)
            p[j] = false;
        prime.push_back(i);
    }
}

int CntPrime(int n){
    vector<int>::iterator it = lower_bound(prime.begin(), prime.end(), n);
    if( *it > n) it--;
    return (it - prime.begin() + 1);
}

int main(){
    init();
    int n;
    while(cin >> n){
        cout << CntPrime(n)<< endl;
    }
    return 0;
}

C++: #include<iostream>
 
using namespace std;
 
int main(){
  static bool cmp[1000000]={true};
  static int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
    cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1]+!cmp[i];
  }
  int n;
  while(cin>>n){
    cout<<npr[n]<<endl;
  }
  return 0;
}

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

int main(){
    int n, t;
    while(cin >> n){
      t = 0;
      for(int i = 2;i <= n;++i){    
        for(int j = 2;j < i;++j){
          if(i % j == 0) break;
          if(j == i - 1) ++t;
        }
      }
      if(n >= 2) ++t;
      cout << t << endl;
    }
  return 0;
}

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

const int MAX=1000000;
int N;
vector<int>ip(1000001,1);
int ans=0;




int main(){
	for(int i=2;i<1000;i++){
		if(ip[i]){
			for(int j=0;i*(j+2)<1000000;j++){
				ip[i*(j+2)]=0;
			}
		}
	}
	ip[0]=0;
	ip[1]=0;


	while(cin>>N){

		for(int i=0;i<=N;i++){
			if(ip[i])ans++;
		}
	

		cout<<ans<<endl;
		ans=0;

	}


	
}

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

using namespace std;

const int INF=1000000;

int main()
{
    int pri[INF];
    int res[INF];
    for(int i=0;i<INF;i++)
        pri[i]=0;
    for(int i=2;i*i<INF;i++)
    {
        if(pri[i]==0)
        {
            for(int j=i*2;j<INF;j+=i)
            {
                pri[j]=1;
            }
        }
    }
    int n=0;
    for(int i=2;i<INF;i++)
    {
        if(pri[i]==0)
            n++;
        res[i]=n;
    }
    int C;
    while(cin>>C)
    {
        cout<<res[C]<<endl;
    }
}

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

bool prime[1000000];

int main()
{
    int i,j,k,l,m,n;
    int count;
    while(cin>>n)
    {
        memset(prime,0,sizeof(prime));
        prime[1]=1;
        prime[2]=0;

        count=0;

        for(j=2;j*j<=n;j++)
        {
            if(prime[j]==0)
            {
                for(k=2;k*j<=n;k++)
                {
                   prime[j*k]=1;
                }
            }
        }
        for(i=1;i<=n;i++)
        {
            if(prime[i]==0)
            count++;
        }
        cout << count << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int n,i;
i=0;
vector<int> an(1000000),as(1000000);
an[0]=2;
  for(int j=3;j<1000000;j++){
   for(int u=0;u<1000000;u++){
if(an[u]==0){
an[u]=j;
break;
}
if(j%an[u]==0){
break;
}
else{
continue;
}
}
}
   for(int u=1;u<1000000;u++){
if(u==an[i]){
as[u]=as[u-1]+1;
}
else{
as[u]=as[u-1];
}
}
for(int i=0;i<30;i++){
   cin>>n;
cout<<as[n]<<endl;
}

C++: #include <iostream>

int main() {
	int n;
	while (std::cin >> n)
	{
		int c = 0;
		for (int i = 2; i <= n; ++i) {
			int j = 2;
			while (i%j)
			{
				++j;
			}
			if (i == j) {
				++c;
			}
		}
		std::cout << c << std::endl;
	}
	}

C++: #include <iostream>
#include <list>
#include <algorithm>
 
using namespace std;
 
int main() {
int n;
 
while(!cin.eof()) {
cin >> n;
list<int> search_list(n-1);
list<int> prime_number;
while(n!=1) {
search_list.push_front(n);
n--;
}
while(!search_list.empty()) {
int m = search_list.front();
prime_number.push_back(m);
search_list.pop_front();
list<int>::iterator it = search_list.begin();
while(it!=search_list.end()) {
if((*it % m) == 0){
it = search_list.erase(it);
continue;
}
it++;
}	
}
cout << prime_number.size()-1 << endl;
}
}

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

using namespace std;



bool Prime(int n)
{
	if((n==1)||(n==0))
	{
		return false;
	}
	for(int i=2;i<=(int)sqrt((double)n);++i)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}

int main()
{
	int n;
	while(cin>>n)
	{
		int count = 0;
		for(int i=0;i<=n;++i)
		{
			if(Prime(i))
			{
				++count;
			}
		}
		cout<<count<<endl;
	}
	return 0;
}