Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		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:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

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

using namespace std;
const int MAX = 1000000;
vector <int> primeCountList(MAX, 0);//indx:number value:primeCount

void setPrimeCount()
{
    int primeCount = 1;
    for(int i=3;i<=MAX;i+=2)
    {
        bool isPrime = true;
        for(int j=3;j*j<=i;j+=2)
        {
            if(i%j == 0)
            {
                isPrime = false;
                break;
            }
        }
        primeCountList[i-1] = primeCount;
        if(isPrime)
        {
            primeCount++;
            primeCountList[i] = primeCount;

        }
        else
        {
            primeCountList[i] = primeCount;
        }

    }
    primeCountList[2] = 1;

}
/*
 * getPrimeNumber:0009
 */
int main()
{
    setPrimeCount();
    int n;
    while(cin >> n)
    {
        cout << primeCountList[n] << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int isprime(int x){
	if(x < 2){
		return false;
	}else if(x==2){
		return true;
	}else{
		for(int i=3;i<x;i=i+2){
			if(x%i==0){
				return false;
			}
		}
		return true;
	}
}
int main(){
	int n;
	while((cin >> n)){
	int a = 0;
	for(int i=2;i<=n;i++){
		if(isprime(i)){
			a++;
		}
	}
	cout << a << endl;
	}
	return 0;
}