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 <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int prime(int a)
{
	if(a<2)
	return 1;

	for(int i=2 ; (i*i)<=a ; i++)
	{
		if(a%i==0)
		return 0;
	}
	
	return 1;
}

int main()
{
	int a;
	int pm[200000];
	int z=0;
	forin(i,2,1000000)
	{
		if(prime(i)==1)
		{
			pm[z]=i;
			z++;
		}
	}
	
	
	while(scanf("%d",&a)!=EOF)
	{
		forin(i,0,z)
		{
			//debugdd(pm[i],a);
			if(pm[i]>a)
			{
				printf("%d\n",i);
				break;		
			}
		}
	}
	return 0;
}

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

int main(){
        int prime[999999];
        bool is_prime[1000000];
        int p =0;
        int n ;
        int i;
        while(cin >> n){
        for(i=0;i<=n;i++) is_prime[i] = true;
        is_prime[0] = is_prime[1] = false;
        for(i=2;i<=n;i++){
                if(is_prime[i]){
                        prime[p++] = i;
                        for(int j=2*i;j<=n;j+=i) is_prime[j] = false;
                }
        }
        cout << p << endl;
        p = 0;
        }
return 0;
}
[tebora@tebora cpp]$ cat  pr.cpp
#include <iostream>
using namespace std;

int main(){
        int prime[999999];
        bool is_prime[1000000];
        int p =0;
        int n ;
        int i;
        while(cin >> n){
        for(i=0;i<=n;i++) is_prime[i] = true;
        is_prime[0] = is_prime[1] = false;
        for(i=2;i<=n;i++){
                if(is_prime[i]){
                        prime[p++] = i;
                        for(int j=2*i;j<=n;j+=i) is_prime[j] = false;
                }
        }
        cout << p << endl;
        p = 0;
        }
return 0;
}

C++: #include <iostream>
using namespace std;
bool t[999999] = {false};
int main()
{
	int n, c, i, j;
	t[0] = true;
	for (i = 2; i <= 999999; i++)
	{
		if (!t[i-1])
		{
			for (j = i+i; j < 999999; j+=i)
				t[j-1] = true;
		}
	}
	while (cin >> n)
	{
		if (cin.eof()) break;
		for (i = c = 0; i < n; i++)
			if (!t[i]) c++;
		cout << c << endl;
	}
}

C++: #include<stdio.h>
const int size=1000000;
int main(){
  int i,k,n;
  int data[size];
  for(i=2;i<size;i++){
    data[i]=1;
  }
  for(i=2;i<size;i++){
    if(data[i]){
      for(k=2*i;k<=size;k+=i){
        data[k]=0;
      }
    }
  }
  while(scanf("%d",&n)!=EOF){
    int cnt=0;
    for(i=2;i<=n;i++){
      if(data[i])cnt++;
    }
    printf("%d\n",cnt);
  }
}

C++: #include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
typedef long long lint;
typedef vector<int> vi;

const int mod = 1e9 + 7;

lint gcd(lint a, lint b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}

// ?????????????????????????????????????????????
lint extgcd(lint a, lint b, lint& x, lint& y) {
	lint d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}

bool is_prime(lint n) {
	for (lint i = 2; i * i <= n; ++i) {
		if (n % i == 0) return false;
	}
	return true;
}

// n????´???° ???????????????unsorted
/*
vi divisor(lint n) {
	vi res;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			res.pb(i);
			if (n / i != i) res.pb(n / i);
		}
	}

	return res;
}*/
vector<lint> divisor(lint n) {
	vector<lint> res;
	deque<lint> d;

	lint i = sqrt(n);
	if (i * i == n) {
		d.push_back(i);
		i--;
	}
	for (; i > 0; --i) {
		if (n % i == 0){
			d.push_front(i);
			d.push_back(n / i);
		}
	}

	res.insert(res.begin(), d.begin(), d.end());
	return res;
}


// 2 * 2 * 3 * 5 * 5 * 5 = {2:2, 3:1,5:3} ???????????? map ????????£????????????
map<int, int> prime_factor(lint n) {
	map<int, int> res;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			++res[i];
			n /= i;
		}
	}

	if (n != 1) res[n] = 1;
	return res;
}

const int MAX_N = 2020202;
vi prime;
bool memo[MAX_N + 1];

// ?´???°?????¨?????? n??\???????´???°????????°?????????
int sieve(int n) {
	prime.clear();
	memset(memo, true, sizeof(memo));
	memo[0] = memo[1] = false;

	for (int i = 2; i <= n; ++i) {
		if (memo[i]) {
			prime.pb(i);
			for (int j = i; j <= n; j += i) {
				memo[j] = false;
			}
		}
	}

	return prime.size();
}

const lint MAX_LEN = 1000000;
const lint MAX_SQRT_B = 1000000;
bool memo_all[MAX_LEN];         //i means i + a
bool memo_small[MAX_SQRT_B];

// [a, b)????´???°????????°???????????????
lint count_prime(lint a, lint b) {
	for (int i = 0; (lint)i * i < b; i++) memo_small[i] = true;
	for (int i = 0; i < b - a; i++)     memo_all[i] = true;

	for (int i = 2; (lint)i * i < b; i++) {
		if (memo_small[i]) {
			for (int j = 2; (lint)j * j < b; j += i) memo_small[j] = false;
			for (lint j = max(2LL, (a + i - 1) / i) * i; j < b; j += i) memo_all[j - a] = false;
		}
	}

	lint ret = 0;
	for (lint i = a; i < b; i++) {
		if (memo_all[i]) ret++;
	}
	return ret;
}

// k???????????§????????£??????????????°??????{a_0 : 0, a_1 : 1, a_2 : 1, ... }
lint Fib[101010];
int calcFib(int k) {
	Fib[0] = 0;
	Fib[1] = Fib[2] = 1;
	for (int i = 3; i <= k; ++i) {
		Fib[i] = Fib[i - 1] + Fib[i - 2];
		// Fib[i] %= mod;
	}

	return Fib[k];
}


int main() {
	lint n;
	
	while (cin >> n) {
		cout << sieve(n) << endl;
	}
}