Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := 2; j < MAX/i; j++ {
                                if i * j < MAX {
                                        primes[i*j] = 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;
            }
            if (i / 3 < 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;
}

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

int main() {
	int n;

	while (cin >> n) {
		int count = 0;
		bool table[1000001] = { false };
		int upper = sqrt(n);

		table[1] = true;

		for (int i = 1; i <= upper; i++) {
			if (table[i] == false) {
				table[i] = true;
				count++;
				for (int j = i; j <= n; j++) {
					if (j % i == 0) {
						table[j] = true;
					}
				}
			}
		}

		for (int i = 1; i <= n; i++) {
			if (table[i] == false) {
				count++;
			}
		}

		cout << count << '\n';
	}

	return 0;
}

C++: #include <iostream>
#include <cstring>
using namespace std;
const int maxn=1000010;
int prime[maxn];
bool isprime[maxn];

int prime_cnt(int n)
    {
        int p=0;
        memset(isprime,true,sizeof(isprime));
        isprime[0]=false;
        isprime[1]=false;
        for (int i=2;i<=n;i++)
            {
                if(isprime[i])
                    {
                        prime[p++]=i;
                        for (int j=2*i;j<=n;j+=i)
                            isprime[j]=false;
                    }
            }
        return p;
    }
int main()
    {
        int n;
        while (cin>>n)
            {
                cout<<prime_cnt(n)<<endl;
            }
        return 0;
    }

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

int main(){
  int n;
  int i,j;
  while(scanf("%d", &n) != EOF){
    int m=1;
    for(i=2;i<=n;i++){
      for(j=2;j<n;j++){
	if(i%j == 0)
	  break;
	if(j==i-1 && i%j!=0)
	  m++;
      }
    }
    printf("%d\n",m);
  }
  return 0;
}