Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2 || num == 5:
		return true
	case num < 2 || num%2 == 0 || num%5 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

C++: #include <iostream>

#define rep(i, n) for(int i = 2; i < n; i ++)

using namespace std;

int main(void){
	const int N = (int)1e6;
	bool num[N];
	rep(i, N) num[i] = true;
	for(int i = 2; i * i < N; i ++) if(num[i]) for(int j = i; i * j < N; j ++) num[i * j] = false;

	for(int n, count = 0; cin >> n; cout << count << endl, count = 0)
		rep(i, n + 1) if(num[i]) count ++;

	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM 1000000
using namespace std;

bool num[MAXNUM];
void erast(int n){
  FOR(i, 2, floor(sqrt(n))+1){
    if(num[i]){
      FOR(j, 2, n){
        if(i*j>=MAXNUM) break;
        num[i*j] = false;
      }
    }
  }
}

int main(){
  int n;
  REP(i, MAXNUM)  num[i] = true;
  num[0]=false;
  num[1]=false;
  while(cin >> n){
    int ans=0;
    erast(n);
    REP(i, n+1){
      if(num[i]){
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

#define pb push_back

using namespace std;

const int MAX=100000;
int main(void)
{
	int x;
	bool p[MAX];
	int cnt;
	int i1,i2;

	fill(p,p+MAX,false);

	for(i1=2;i1<MAX;i1++){
		for(i2=2;i2*i2<=i1;i2++){
			if(i1%i2==0) break;
		}
		if(i2*i2>i1) p[i1]=true;
	}

	while(1){
		cin>>x;
		if(x==EOF) break;

		cnt=0;
		for(i1=0;i1<=x;i1++){
			if(p[i1]) cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

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

int main()
{
	bool num[1000000] ;
	for( int i = 0 ; i < 1000000 ; i ++ )
	{
		num[i] = false ;
	}

	int count = 0 ;
	int get ;
	while( cin >> get )
	{
		for( int i = 2 ; i <= get ; i ++ )
		{
			if( num[i] == false )
			{
				for( int j = 1 ; j < (get/i) ; j ++ )
				{
					num[i+(j*i)] = true ;
				}

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

		for( int i = 0 ; i < get ; i ++ )
		{
			num[i] = false ;
		}
	}

	return 0 ;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM 1000000
using namespace std;

int num[MAXNUM]={0};

int main(){
  int n;
  while(cin >> n){
    vector<int> vec;
    vec.push_back(2);
    for(int i = 3; i<=n; i+=2){
      if(num[i]==1) continue;
      FOR(j, 2, MAXNUM){
        if(i*j>n)  break;
        num[i*j]=1;
      }
      vec.push_back(i);
    }
    cout << vec.size() << endl;
  }
  return 0;
}

C++: 
#include <cstdio>
#include <iostream>
using namespace std;
int list[1000000],p[80000];
int sum[1000000];

void gets()
{
    p[0]=2;
    int key=0;
    for(int i=0;i<1000000;i++)
        list[i]=i%2;
    for(int i=3;i<1000000;i+=2)
        if(list[i])
    {
        p[++key]=i;
        for(int j=2*i;j<1000000;j++)
            list[j]=0;
    }
}

int main()
{
    gets();
    for(int i=0;i<1000000;i++)
        sum[i]=0;
    for(int i=0;i<80000;i++)
        sum[p[i]]=1;
    for(int i=1;i<1000000;i++)
        sum[i]+=sum[i-1];
    int n;
    while(cin>>n)
        cout<<sum[n]<<endl;
    return 0;
}

C++: #include <iostream>
#include <cstring>
#define STA 1000000
using namespace std;

bool prime[STA];

int main(){
    memset(prime,true,sizeof(prime));
    for(int i=2;i<STA;i++){
        for(int j=2;i*j<STA/2;j++) prime[i*j] = false;
    }
    int n;
    while(cin >> n){
        int cnt = 0;
        for(int i=2;i<=n;i++){
            if(prime[i]) cnt++;
        }
        cout << cnt << endl;
    }
}

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

#define MAX_NUM (1000000)

int main(void)
{
  static bool searchList[MAX_NUM];
  static bool isPrime[MAX_NUM];
  static int primeNum[MAX_NUM];
  
  double maxSq = sqrt((double)(MAX_NUM - 1));
  
  for (int i = 2; i <= maxSq + 1; i++) {
    if (!searchList[i]) {
      isPrime[i] = true;
      for (int j = 2; j < MAX_NUM; j++) {
        if (j % i == 0) {
          searchList[j] = true;
        }
      }
    }
  }
  
  for (int i = maxSq + 2; i < MAX_NUM; i++) {
    if (!searchList[i]) {
      isPrime[i] = true;
    }
  }
  
  
  for (int i = 2; i < MAX_NUM; i++) {
    primeNum[i] = isPrime[i] ? primeNum[i - 1] + 1 : primeNum[i - 1];
  }
  
  int n;
  while (std::cin >> n) {
    std::cout << primeNum[n] << std::endl;
  }
  
  return 0;
}

C++: //
//  main.cpp
//  CppTest
//
//  Created by Ryu on 2017/02/08.
//  Copyright ?? 2017??´ Ryu. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    long in[30];
    long out[30];
    int n = 0;
    long max = 0;
    while(cin >> in[n]){
        if(max < in[n]){
            max = in[n];
        }
        n++;
    }
    //printf("%d", n);
    
    long p[100000];
    p[0] = 2;
    int m = 1;
    for (int i = 3; i <= max; i += 2) {
        bool prime = true;
        for(int j = 0; j < m; j++){
            if (i % p[j] == 0) {
                prime = false;
                break;
            }
            if (i / 5 < p[j]) {
                break;
            }
        }
        if (prime) {
            p[m] = i;
            //printf("%ld\n", p[m]);
            m++;
        }
    }
    
    
    for (int i = 0; i < n; i++) {
        int s = 0;
        while (in[i] >= p[s] && p[s] != 0) {
            //printf("in: %ld, p: %ld\n", in[i], p[s]);
            s++;
        }
        out[i] = s;
        printf("%ld\n", out[i]);
    }
    
    return 0;
}