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>

int	main(){
	int	i,	k,	x,	cnt,	data[1000000];
	for(i	=	2;	i	<=	1000000;	i++){
		data[i]	=	1;
	}
	for(i	=	2;	i	*	i	<=	1000000;	i++){
		if(data[i]){
			for(k	=	2	*	i;	k	<=	1000000;	k	+=	i){
				data[k]	=	0;
			}
		}
	}
	while(1){
		cnt	=	0;
		scanf("%d",	&x);
		if(x	==	0)break;
		for(i	=	2;	i	<=	x;	i++){
			if(data[x]	==	1)cnt++;
		}
		printf("%d\n",	cnt);
	}
	return	0;
}

C++: #include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

const int size=1000000;
vector<int> map(size,1);
void sieve(int p)
{
    for(int j=p*2;j<size;j+=p)
    {
        map[j]=0;
    }
}
int main(void)
{
    int n;
    scanf("%d",&n);
    map[0]=0;
    map[1]=0;
    sieve(2);
    for(int i=7;i<1000;i+=6)
    {
        sieve(i);
        sieve(i+4);
    }
    printf("%d\n",count(map.begin(),map.begin()+n+1,1));
    return 0;
}

C++: #include <cstdio>
#define max_n 999999
int prime[max_n];
bool is_prime[max_n+1];
int main(){
    for(int i=0; i<max_n; i++){
        is_prime[i]=true;
    }
    int p = 0;
    is_prime[1]=false;
    is_prime[0]=false;
    for(int i=2;i<max_n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<max_n;j+=i)is_prime[j]=false;
        }
    }
    int n;
    while(scanf("%d",&n)!=EOF){
        
        
        int ans = 0;
        for(int i =0; i<max_n; i++){
            if(prime[i]>n){
                ans = i;
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    vector<int> prime;
    prime.push_back(2);
    for (long long int i = 3; i < 999999; i++)
    {
        double temp = sqrt(i);
        for (int j = 0;; j++)
        {
            if (temp < prime[j])
            {
                prime.push_back(i);
                break;
            }
            if (i % prime[j] == 0)
            {
                break; //this is not prime
            }
        }
    }
    int n;
    int i;
    while (cin >> n)
    {
        for (i = 0; i<prime.size()&&prime[i] <= n; i++);
        cout << i << endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<cstring>
int main(){
 int n,cnt=0;
 scanf("%d",&n);
 int a[n+1];
 memset(a,-1,sizeof(int)*(n+1));
 for(int i=2;i<=n;i++){
 if(a[i]==-1){ cnt++;
 for(int j=i;j<=n;j=j+i) a[j]=0;}
}
printf("%d",cnt);
return 0;
}

C++: #include<stdio.h>
int flg[1000000];
int main(void)
{
    int n,i,j,x;
	
    while(scanf("%d",&n)!=EOF){
		for(i=2;i<=n;i++)	{
			flg[i]=1;
		}
		for(i=2;i*i<=n;i++){
			if(flg[i]==1){
				for(j=2;j*i<=n;j++){
					flg[i*j]=0;
				}
			}
		}
		x=0;
		for(i=2;i<=n;i++)	{
			if(flg[i]==1){
				x++;
			}
		}
		printf("%d\n",x);
	}
	return 0;
}

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

bool prime[MAX]={};

void run(){
  for(int i=2;i<MAX;i++){
    prime[i]=true;
  } 

  for(int i=2;i<MAX;i++){
    if(!prime[i])continue;
    for(int j=2;j*i<MAX;j++){//i*1 is prime number
      prime[i*j]=false;
    }
  }
  return;
}

int main(){

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

}

C++: #include <iostream>                                                                                                     
#include <vector>                                                                                                       
                                                                                                                        
using namespace std;                                                                                                    
                                                                                                                        
int main() {                                                                                                            
  int n;                                                                                                                
  int count;                                                                                                            
  while (cin >> n) {                                                                                                    
    if (n == 1) { cout << 0 << endl; return 0; }                                                                        
    if (n == 2) { cout << 1 << endl; return 0; }                                                                        
                                                                                                                        
    vector<int> prime_numbers; // 素数リスト                                                                            
    prime_numbers.push_back(2);                                                                                         
    count = 1;                                                                                                          
    for (int i = 3; i <= n; i++) {                                                                                      
      bool prime = true;                                                                                                
      for (vector<int>::iterator itr = prime_numbers.begin(); itr != prime_numbers.end(); itr++) {                      
        if (i % *itr == 0) {                                                                                            
          prime = false;                                                                                                
          break;                                                                                                        
        }                                                                                                               
      }                                                                                                                 
      if (prime) {                                                                                                      
        prime_numbers.push_back(i);                                                                                     
        count += 1;                                                                                                     
      }                                                                                                                 
    }                                                                                                                   
    cout << count << endl;                                                                                              
  }                                                                                                                     
  return 0;                                                                                                             
}