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 <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> ll_i;
struct edge { int u, v; ll w; };

void sieve(int n, bool a[]) {
	fill(a, a + n, true);
	a[0] = a[1] = false;
	for (int i = 2; i * i < n; i++)
		if (a[i])
			for (int j = i * 2; j < n; j += i)
				a[j] = false;
}

bool a[1000000];
int b[1000000];

int main() {
	sieve(1000000, a);
	for (int i = 1; i < 1000000; i++)
		b[i] = b[i - 1] + (a[i] ? 1 : 0);
	int n;
	while (cin >> n) cout << b[n] << endl;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,a[9];
	a[0]=9592;
	a[1]=17984;
	a[2]=25997;
	a[3]=33860;
	a[4]=41538;
	a[5]=49098;
	a[6]=56543;
	a[7]=63951;
	a[8]=71274;
	while(cin>>n){
		int count=0;
		int i=0;
		while(true){
			if((i+1)*100000<=n)
				count=a[i];
			else
				break;
			i++;
		}
		if(n<100000){
			count=1;
			for(int j=3;j<=n;j++){
			bool t=false;
			for(int k=2;k<1+(double)sqrt((double)j);k++){
				if(j%k==0)
					t=true;
			}
			if(t==false)
				count++;
		    }
		}
		else{
		    for(int j=(i)*100000+1;j<=n;j++){
			    bool t=false;
			    for(int k=2;k<1+(double)sqrt((double)j);k++){
				    if(j%k==0)
				        t=true;
			    }
			    if(t==false)
				    count++;
		    }
		}
		cout<<count<<endl;
	}
	return 0;
}

C++: #include <stdio.h>
int main()
{
  int i,j,cou=0,n;
  while(scanf("%d",&n)!=EOF){
    cou=0;
    for(i=2;i<=n;i++){
      if(i==2){
	cou++;
	continue;
      }
      for(j=2;j<i;j++){
	if(i%j==0)break;
	if(j==i-1)cou++;
      }
    }
    printf("%d\n",cou);
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int n,i,j;
  while(scanf("%d",&n)!=EOF){
    vector<int> v(1000000,0);
    for(i=2;i<n+1;i++){
      if(v[i])continue;
      for(j=2;i*j<n+1;j++)
	v[i*j]=1;
    }
    int sum=0;
    for(i=2;i<n+1;i++)
      if(v[i]==0)sum++;
    cout<<sum<<endl;
  }
}

C++: #include <iostream>

using namespace std;

int prime(int n)
{
	if(n < 2){
		return 0;
	} else if(n == 2){
		return 1;
	}
	
	if(n % 2 == 0){
		return 0;
	}
	
	for(int i = 3; i*i <= n; i+= 2){
		if(n % i == 0){
			return 0;
		}
	}
	
	return 1;
}

int main(int argc, char **argv)
{
	int n, c;
	
	while(cin >> n){
		c = 0;
		for(int i = 2; i <= n; i++){
			if(prime(i) == 1){
				c++;
			}
		}
		
		cout << c << endl;
	}
	
	return 0;
}

C++: #include<stdio.h>
int main(){
	int a,b,c,n;
	0<n<1000000;
	c=0;
	scanf("%d",&n);
	for(a=1;a<=n;a++){
		for(b=2;b<=n;b++){
			if(a%b==0&&a!=b){
				break;
			}else if(a%b==0&&a==b){
				c++;
			}else{
			}
		}
	}
	printf("%d\n",c);
	return 0;
}

C++: #include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;

#define max 1000000

int main(){
	bool is_prime[max] = {};
	for (int i = 2; i < max; ++i) {
		is_prime[i] = 1;
	}
	for (int i = 0; i < max; ++i) {
		if (is_prime[i]) {
			for (int j = i + i; j < max; j += i) {
				is_prime[j] = 0;
			}
		}
	}
	int num_prime[max] = {};
	for (int i = 1; i < max; ++i) {
		num_prime[i] = num_prime[i-1] + is_prime[i];
	}
	int n;
	while (cin >> n) {
		cout << num_prime[n] << endl;
	}
	return 0;
}

C++: #pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	memset(vis, 0, sizeof(vis));
	memset(prime, 0, sizeof(prime));
	prime[0] = prime[1] = 0;
	int n;
	cin >> n;
	for (int i = 2; i<=n; i++){
		if (!vis[i]){
			
			prime[i] = 1;
			for (int j = i+i; j<=n; j += i){
				vis[j] = 1;
				prime[j] = 0;
				
		}
	}
	int sum = 0;
	for (int i = 2; i <= n; i++){
			if (prime[i]){
				sum++;
			}
		}
		cout << sum << endl;
	return 0;
}

C++: #include<iostream>

using namespace std;



bool Prime(int n)
{
	if((n==1)||(n==0))
	{
		return false;
	}
	for(int i=2;i<=(int)sqrt((double)n);++i)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}

int main()
{
	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 <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
using namespace std;
typedef pair<int,int> P;
const int INF = (int)((unsigned int)-1>>1);


int main(){
    vector<int> prime;
    prime.push_back(2);

    for(int i=3;i<=999999;i+=2){
        bool is_prime = true;
        for(int j=0;j<prime.size();j++){
            if (prime[j]*prime[j] > i) break;
            if (i % prime[j] == 0){
                is_prime = false;
                break;
            }
        }
        if(is_prime){
            prime.push_back(i);
        }
    }

    int n;
    while(cin >> n){
        int ans = 0;
        for(int j=0;j<prime.size();j++){
            if (prime[j] > n) break;
            ans++;
        }
        cout << ans << endl;
    }

    return 0;
}

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

int main(){
	bool p[MAX+1];
	int n, ans;

	for(int i=0 ; i<=MAX ; i++){
		p[i] = (i<=1)? false : true ;
	}

	for(int i=2 ; i<=sqrt((long double)MAX)+1 ; i++){
		if(p[i]){
			for(int j=i*2 ; j<=MAX ; j+=i){
				p[j] = false;
			}
		}
	}

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

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

using namespace std;
#define MAX_NUM 10000000
vector<int> p;
int flag[MAX_NUM/32+1];

//sieve eratosthenes
void setPrime(vector<int> &p){

    for(int i=1;2*i*(i+1)<(MAX_NUM>>1);++i){

        if(flag[i>>5] & (1<<(i%32)))continue;
        //(2*j+1) == (2*i+1)*(2*i+1)
        //(2*i+1)*(2*i+1) -> (2*i+1)*(2*(i+1)+1) -> ... set not prime
        for(int j=2*i*(i+1); j<(MAX_NUM>>1); j+=2*i+1)
            flag[j>>5] |= (1<<(j%32));

    }

    p.push_back(2);
    for(int i=1;2*i+1<=MAX_NUM;++i){
        for(;flag[i>>5] & (1<<i);++i);
        if(2*i+1>MAX_NUM)break;
        p.push_back(2*i+1);
    }

}

int ans[1000001];
int cnt = 0;

int main(){

    vector<int> primes;
    setPrime(primes);

    for(int i=0;i<=1000000;++i){

        if(primes[cnt]==i)++cnt;

        ans[i]=cnt;

    }

    int N;
    while(cin>>N){

        cout << ans[N] << endl;

    }

    return 0;
}