Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>

using namespace std;

int main() {

	int n, count = 0;
	int a[9999] = { 0 };
	
	// ??¨???????????????????????????

	while (cin >> n){

		for (int i = 2; i <= n; i++) {
			a[i] = 1;
		}

		for (int i = 2; i < sqrt(n); i++) {
			if (a[i]) {
				for (int j = 0; i*(j + 2) <= n; j++) {
					a[i * (j + 2)] = 0;
				}
			}
		}

		for (int i = 2; i <= n; i++) {
			if (a[i] == 1)
				count++;
		}

		cout << count << endl;
		count = 0;
	}

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int n;
int main(){
	while(cin>>n){
		int sum=0;
		if(n<=100000){
			for(int i=2;i<=n;i++){
				for(int j=2;j<=sqrt(i);j++){
					if(i%j==0){
						goto loopa;
					}
				}
				sum++;
				loopa:;
			}
			cout<<sum<<endl;
		}
		else{
			for(int i=100001;i<=n;i++){
				for(int j=2;j<=sqrt(i);j++){
					if(i%j==0){
						goto loopb;
					}
				}
				sum++;
				loopb:;
			}
			cout<<sum+9592<<endl;
		}
	}
	return 0;
}

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

const int MAX_N = 999999;
int prime[MAX_N];
bool is_prime[MAX_N + 1];

int sieve(int n)
{
	int p = 0;
	for (int i = 0; i <= n; i++)
		is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;

	for (int i = 2; i <= n; i++)
	{
		if (is_prime[i])
		{
			prime[p++] = i;
			for (int j = i * 2; j <= n; j += i)
				is_prime[j] = false;
		}
	}
		return p;
}

int main()
{
	int n;
	while (scanf("%d", &n) != EOF)
	{
		int ans = sieve(n);
		printf("%d\n", ans);
	}
	return 0;
}

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

int p[MAX];

int main(){
	int counter = 0;
	p[1] = 0;
	for (int i = 2; i < MAX; i++){
		int sqrti = (int)sqrt(i);
		counter++;
		p[i] = counter;
		for (int j = 2; j <= sqrti; j++){
			if (i % j == 0){
				counter--;
				p[i] = counter;
				break;
			}
		}
	}
	int n;
	while (cin >> n){
		cout << p[n] << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(){ 
    int n;
    scanf("%d",&n);
    int prime[999999]={};
    for(int i=2;i<=n;i++){ 
        for(int j=2;i*j<=n;j++){ 
            prime[i*j]=1;
        }
    }
    int ans=0;
    for(int i=2;i<=n;i++){
        if(prime[i]==0)ans++;
    }
    printf("%d\n",ans);
}

C++: #include <iostream>
using namespace std;
#define x 1000000
int main(){
	bool q[x];
	for(int i=2;i<x;i++) q[i] = true;
	for(int i=2;i<x;i++) if(q[i]) for(int j=2;j<=x/i;j++) q[i*j] = false;
	int n;
	while(cin >> n){
		int a = 0;
		for(int i=2;i<=n;i++) if(q[i]) a++;
		cout << a << endl;
	}
}

C++: #include <iostream>
using namespace std;
#define max 1000000
 
int main()
{
    int prime[max];
    
    fill(prime, prime + max, 1);
    prime[0] = 0;
    prime[1] = 0;
    for (int i = 2; i < max; i++) {
        if (prime[i]) {
            for (int j = 2*i; j < max; j += i) {
                prime[j] = 0;
            }
        }
    }
    
    for(int i = 1;i < max; i++){
	    prime[i] = prime[i] + prime[i-1];
    }
    
    int aaa;
    while (cin >> aaa) {
	cout << prime[aaa] << endl;
    }
    return 0;
}

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

bool *f;

int main(){
	int n;
	while(cin>>n){
		f=new bool[n+1];
		for(int i=0;i<n;i++) f[i]=false;
		f[0]=true;
		f[1]=true;
		int l=sqrt(n);
		for(int i=2;i<=l;i++){
			for(int j=2;j*i<=n;j++){
				f[j*i]=true;
			}
		}
		int cnt=0;
		for(int i=0;i<=n;i++) if(!f[i])cnt++;
		cout<<cnt<<endl;
		delete []f;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <math.h>

using namespace std; 

int list[1000000]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163,
 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251,
 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443,
 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557,
 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647,
 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757,
 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983,
 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069};

long int a,b,loop,hasil,input,mid;
long int lo;
long int hi;

 bool Prima(unsigned long n) 
{
    for (unsigned short i = 0; list[i]*list[i] <= n; i++) 
	{
        if (n % list[i] == 0) 
		{
            return false;
        }
    }
 
    return true;
}

int main()
{
	lo=1087;
	a=180;
	while(lo<=100003)
	{
		if(Prima(lo))
		{
			list[a]=lo;
			a++;
		}
		lo+=2;
	}
	//printf("%d",list[78498]);
	while(scanf("%ld",&input)!= EOF)
	{	
	lo=0;
	hi=78497;
	/*while(lo<=hi)
        {
            mid=(lo+hi)/2;
            if (list[mid]<input)
            {
                lo=mid+1; 
            } 
            else if(list[mid]>input)
            {
                hi=mid-1; 
            }
            else 
            {
                break; 
            } 
        }*/
	while(input>=list[lo])
	{
		lo++;
	}
	printf("%d\n",lo);
	}
	return 0; 
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM 1000000
using namespace std;

int num[MAXNUM]={0};

int main(){
  int n;
  vector<int> vec;
  vec.push_back(2);
  while(cin >> n){
    for(int i = 3; i<=n; i+=2){
      if(num[i]==1) continue;
      FOR(j, 1, MAXNUM){
        if(i*j>=n)  break;
        num[i*j]=1;
      }
      vec.push_back(i);
    }
    for(int i=0; i<=vec.size(); i++){
      if(vec[i]>n || i==vec.size()){
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}