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>

using namespace std;

const int iMAX = 1000000;
const int iMAX_half = 500000;
int isPrime[iMAX];

int main()
{
	int n, cnt, sqSize;
	bool prime[iMAX_half];

	cnt = 1;
	sqSize = 1000;
	prime[0] = prime[1] = 0; prime[2] = 1;
	for(int i=3; i < iMAX; i+=2) prime[(i-1)>>1] = 1;
	for(int i=3; i < sqSize; i+=2) {
		if(prime[(i-1)>>1]) {
			for(int j=i+i+i; j < iMAX; j+=(i*2))
				if(j & 1) prime[(j-1)>>1] = 0;
		}
	}
	isPrime[0] = isPrime[1] = 0; isPrime[2] = 1;
	for(int i=3; i < iMAX; i+=2) {
		if(prime[(i-1)>>1]) cnt++;
		isPrime[(i-1)>>1] = cnt;
	}
	while(cin >> n)
	{
		if(n == 2)
			cout << 1 << endl;
		else
			cout << isPrime[(n-1)>>1] << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T &n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

bool isprime(int n){
  if(n==2||n==3) return true;
  for(int i=2; i*i<=n; i++) if(n%i==0) return false;
  
  return true;
}

signed main(){
  int n;
  while(cin>>n){
    if(n==1){cout<<0<<en; RE;}
    int ans=0;
    for(int i=2; i<=n; i++){
      if(isprime(i)) ans++;
    }
    cout<<ans<<en;
  }
}

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

bool IsPrime(int m){
    if(m==1){
        return(1);
    }else if(m==2){
        return(1);
    }else if(m%2==0){
        return(0);
    }else{
        for(int i=3;i*i<=m;i+=2){
            if(m%i==0)return(0);
        }
        return(1);
    }
}
int main(){
    int n;
    int r[30];
    for(int i=0;i<30;i++){
        r[i]=0;
    }
    int j=0;
    while((char)n!=' '){
        cin>>n;
        for(int i=1;i<=n;i++){
            if(IsPrime(i))r[j]++;
        }
        cout<<r[j]<<endl;
        j++;
    }
    return(0);
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
   
using namespace std;
   

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define rforeach(it, c) for (__typeof__((c).rbegin()) it=(c).rbegin(); it != (c).rend(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))
#define COPY(dest, src) memcpy(dest, src, sizeof(dest))
#define ten(n) ((long long)(1e##n))
#define bin(n) (1LL << (n))

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

template <class T> void sort(vector<T>& c) { sort(c.begin(), c.end()); }
template <class T> void uniq(vector<T>& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); }

template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
  
template <class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << "( " << p.first << ", " << p.second << " )"; return os; }
  
template <class T> void print(T a, int n, const string& deli = " ", int br = 1) { for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } while (br--) cout << endl; }
template <class T> void print(const T& c, const string& deli = " ", int br = 1) { foreach (it, c) { cout << *it; if (++it != c.end()) cout << deli;--it; } while (br--) cout << endl; }
template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {    if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; }
   
template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
#define trace(x) (cout << #x << ": " << (x) << endl)

bool valid(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }


typedef long long ll;
typedef pair<int, int> pint;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
  
const double PI = acos(-1.0);
const int mod = 1000000007;



class SegmentPrimeTable
{
private:
    vector<bool> table;
    ll lower, upper;
    int index(ll n) const
    {
        assert(lower <= n && n <= upper);
        return n - lower;
    }
public:
    void sieve(ll lower, ll upper)
    {
        assert(lower >= 0);
        this->lower = lower, this->upper = upper;

        ll len = upper - lower + 1;
        table.resize(len);
        fill(table.begin(), table.end(), true);

        vector<bool> p(sqrt(upper) + 128, true);
        if (lower == 0) table[index(0)] = false;
        if (lower <= 1) table[index(1)] = false;
        for (ll i = 2; i * i <= upper; ++i)
        {
            if (p[i])
            {
                for (ll j = i + i; j * j <= upper; j += i)
                    p[j] = false;
                for (ll j = max(i + i, (lower + i - 1) / i * i); j <= upper; j += i)
                    table[index(j)] = false;
            }
        }
    }

    bool is_prime(ll n) const { return table[index(n)]; }
    vector<ll> primes(ll low, ll up) const
    {
        vector<ll> p;
        for (ll i = low; i <= up; ++i)
            if (is_prime(i))
                p.push_back(i);
        return p;
    }
};
vector<bool> prime_table(int upto)
{
    vector<bool> p(upto + 1, true);
    p[0] = p[1] = false;
    for (int i = 2; i * i <= upto; ++i)
        if (p[i])
            for (int j = i + i; j <= upto; j += i)
                p[j] = false;
    return p;
}
int main()
{
    vector<bool> p = prime_table(ten(6));
    int s[ten(6)];
    for (int i = 1; i < ten(6); ++i)
        s[i] = s[i - 1] + p[i];
    int n;
    while (cin >> n)
        cout << s[n] << endl;
}