Go: package main

import (
  "fmt"
  "math"
)

func main() {
  const N = 1000000
  var temp [N+1]bool
  for i:=0; i<N+1; i++ {
    temp[i] = true
  }
  temp[0] = false
  temp[1] = false
  for i:=2; i<int(math.Ceil(math.Sqrt(float64(N+1)))); i++{
    if (temp[i]){
      for j:=i*2; j<N+1; j+=i{
        temp[j] =false
      }
    }
  }
  var a int
  var b int
  for _, err := fmt.Scan(&a); err == nil; _, err = fmt.Scan(&a) {
    b = 0
    for i:=0; i<=a; i++{
      if temp[i] {
        b++
      }
    }
    fmt.Println(b)
  }
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <cmath>
std::vector<int> PRIMES;

void init_primes(int max)
{
  if (max < 2) return;
  std::set<int> candidate;
  PRIMES.push_back(2);
  for (int i = 3; i < max; i+=2) {
    candidate.insert(i);
  }
  for (int i = 3; i < sqrt(max); i+=2) {
    std::set<int>::iterator it = candidate.find(i);
    if (it != candidate.end()) {
      PRIMES.push_back(i);
      int del_num = i;
      while (del_num < max) {
        it = candidate.find(del_num);
        if (it != candidate.end()) candidate.erase(it);
        del_num += i;
      }
    }
  }
  for (std::set<int>::iterator it = candidate.begin();
       it != candidate.end(); ++it) {
    PRIMES.push_back(*it);
  }
}

int main()
{
  const int max = 1000000;
  init_primes(max);
  int i;
  while (std::cin >> i) {
    std::vector<int>::iterator it = PRIMES.begin();
    int n = 0;
    while (*it <= i) {
      n++;
      it++;
    }
    std::cout << n << std::endl;
  }
  return 0;
}

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

int main(){
	bool p[1000000];
	int num[1000000];
	int c,n;
	
	for(int i=0;i<1000000;i+=2)p[i] = false ;

	for(int i=1;i<1000000;i+=2)p[i] = true ;
	
	p[1] = false;
	p[2] = true;
	
	c=3;
	while(c < 1000){
		for(int i=3*c; i < 1000000; i+=2*c)p[i] = false;
		do{c+=2;}while(!p[c]);
	}
	
	c=0;
	for(int i = 0 ; i < 1000000 ; i++){
		if(p[i])c++;
		num[i] = c;
	}
	
	while(cin>>n)cout<<num[n]<<endl;
}

C++: #include<stdio.h>

int pr[50847534];
int x = 0;

int nextpr(int p){
  int nxp = p+2;
  int i;
  int ok;
  x++;
  if(p==2)return 3;
  while(1){
      /*printf("p=%d->",nxp);*/
    for(i=0;pr[i]*pr[i]<=nxp;i++){
      ok = 1;
      if(!(nxp%pr[i])){
        ok = 0;
        break;
      }
    }
    if(ok){
        /*printf("O\n");*/
      return nxp;
    }else{
        /*printf("X\n");*/
      nxp+=2;
    }
  }
}

int main(){
    int n;
    int i;
    pr[0] = 2;
    while(scanf("%d",&n)!=EOF){
        printf("n=%d\n",n);
        i=0;
        if(n-1){
            while(pr[i]<=n){
                /*printf("prime:%d(%d)\n",pr[i],i+1);*/
                i++;
                if(i>=x){
                    pr[i] = nextpr(pr[i-1]);
                }
            }
        }
        printf("%d\n",i);
    }
}

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

typedef long long LL;
using namespace std;

const int X = 1000001;
bool isPrime[X];

void init(){
  for(int i=0;i<X;i++){
    isPrime[i] = false;
  }
  isPrime[2] = true;
  for(int i=3;i<X;i+=2){
    cout << i << endl;
    bool ok = true;
    for(int j=2;j<=sqrt(i);j++){
      if(!isPrime[j])continue;
      if(i%j==0)ok=false;
    }
    if(ok)isPrime[i] = true;
  }
}

int main(){
  init();
  int n;
  while(cin >> n){
    int answer = 0;
    for(int i=0;i<n+1;i++){
      if(isPrime[i])answer++;
    }
    cout << answer << endl;
  }
  return 0;
}

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

using namespace std; 

int list[1000000]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163,
 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251,
 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443,
 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557,
 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647,
 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757,
 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983,
 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069};

long int a,b,loop,hasil,input,mid;
long int lo;
long int hi;

 bool Prima(unsigned long n) 
{
    for (unsigned short i = 0; list[i]*list[i] <= n; i++) 
	{
        if (n % list[i] == 0) 
		{
            return false;
        }
    }
 
    return true;
}

int main()
{
	lo=1087;
	a=180;
	while(lo<=1000003)
	{
		if(Prima(lo))
		{
			list[a]=lo;
			a++;
		}
		lo+=2;
	}
	//printf("%d",list[78498]);
	while(scanf("%ld",&input)!= EOF)
	{	
	lo=0;
	while(input>=list[lo])
	{
		lo++;
	}
	printf("%d\n",lo);
	}
	return 0; 
}

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


int main() {

//変数の宣言

	int i,n,j,sum,judge=1;
	
	while(cin>>n){
		sum = 1;
		for(i=3;i<n+1;i+=2){
			for(j=3;j<=sqrt(i);j+=2){
				if(i%j==0){
					judge = 0;
					break;
				}
			}
			if (judge==1){
				sum++;
			}
			judge = 1;
		}
		
		cout << sum <<endl;
	}

	return 0;
}

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

int main()
{
	
	long int k,p[100000];
	float n;
	p[0]=2;
	while(cin>>n){
	k=0;
	int r=(int)sqrt(n);
	for(int i=3;i<=r;i++){
		for(int j=0;j<k+1;j++){
			if(i%p[j]==0){
				break;
			}else if(j==k){
				k++;
				p[k]=i;
			}
		}
	}
	int r_k=k;
	for(;r<n;r++){
		for(int i=0;i<=r_k;i++){
			if(r%p[i]==0){
				break;
			}else if(i==r_k){
				k++;
			}
		}
	}

	cout<<k+1<<endl;
	}
}

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

int main(){
	int n;
	while(scanf("%d", &n) != EOF){
		int *arr = new int[n + 1];
		int loop = (int)sqrt(n);
		
		for(int i = 2; i <= loop; i++){
			if(arr[i] == 0){
				for(int j = 2*i; j <= n; j += i){
					arr[j] = 1;
				}
			}
		}
		
		int cnt = 0;
		for(int i = 2; i <= n; i++){
			if(arr[i] == 0){
				cnt++;
			}
		}
		delete [] arr;
		
		printf("%d\n", cnt);
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>
 
// #include <unordered_set>
// #include <unordered_map>
 
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
 
#define pb push_back
#define mp make_pair
 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
 
typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;
 
const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
 
using namespace std;
 
#define N 1000000
int arr[N];
int a[N];
 
void eratosthenes(){
    REP(i,N){
        arr[i]=1;
    }
 
    for(int i=2;i<sqrt(N);i++){
        if(arr[i]){
            for(int j=0;i*(j+2)<N;j++){
                arr[i*(j+2)]=0;
            }
        }
    }
    arr[0]=0;
    arr[1]=0;
}
 
signed main(){

    eratosthenes();
    
    int n;
    int count=0;

    while(cin>>n){
        REP(i,n+1){
            if(arr[i]==1)count++;
        }

        cout<<count<<endl;
        count=0;
    }
 
}