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)
	{
		int d=0;
		forin(i,0,z)
		{
			if(pm[i]>a)
			{
				d=i;
				printf("%d\n",d);
				break;		
			}
		}
	}
	return 0;
}

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

int main(){
  int isPrime[1000000];
  for(int i = 2; i < 100000 ; i++)isPrime[i] = 1;
  isPrime[0]  = isPrime[1] = 0; 
  for(int i = 2 ; i*i < 100000 ; i++ ){
    if(isPrime[i])for(int j = i*2 ; j < 100000 ; j+=i)isPrime[j] = 0;
}

  int n;
  while(  cin >> n ){
    int cnt = 0;
    for(int i = 2 ; i <= n ; i++  ){
      if(isPrime[i])cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

int main(){
	bool prime[1000001];
	for(int i = 0; i < 1000001; i++) prime[i] = true;
	prime[0] = false;
	prime[1] = false;
	for(int i = 2; i < 1000; i++){
		for(int j = i*2; j < 1000001; j += i){
			prime[j] = false;
		}
	}

	int n;
	while(cin >> n){
		int count = 0;
		for(int i = 0; i <= n; i ++){
			if(prime[i]) count++;
		}
		cout << count << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	int n;

	while (cin >> n) {
		int counter = 1;
		
		if(n < 1000){
			for (int i = 3; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		}else if(n < 10000){
			counter = 168;
			for (int i = 1001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 100000){
			counter = 1229;
			for (int i = 10001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 200000){
			counter = 9592;
			for (int i = 100001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 300000){
			counter = 17984;
			for (int i = 200001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 400000){
			counter = 25997;
			for (int i = 300001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 500000){
			counter = 33860;
			for (int i = 400001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 600000){
			counter = 41538;
			for (int i = 500001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 700000){
			counter = 49098;
			for (int i = 600001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 800000){
			counter = 56543;
			for (int i = 700001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 900000){
			counter = 63951;
			for (int i = 800001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else {
			counter = 71274;
			for (int i = 900001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		}
		cout << counter << endl;
	}

	return 0;
}

C++: #include <stdio.h>

#define MAX (1000000)

bool primeTbl[MAX];

int main() {
	
	primeTbl[0] = primeTbl[1] = true;
	for(int i=2; i<MAX; i++) {
		if(!primeTbl[i])
			for(int j=i*2; j<MAX; j+=i)
				primeTbl[j] = true;
	}
	printf("ready\n");
	int n;
	while(scanf(" %d", &n)) {
		int ans = 0;
		for(int i=2; i<=n; i++)
			if(!primeTbl[i])
				ans++;
		printf("%d %d\n", n, ans);
	}
	return 0;
}