Go: package main

import "fmt"

func main() {
	const MAX = 1000000
	prime := make([]int, MAX, MAX)
	check := make([]int, MAX, MAX)
	count := make([]int, MAX, MAX)

	prime[0] = 1
	prime[1] = 1

	// prime init
	for i := 2; i < MAX; i++ {
		if check[i] == 1 {
			continue
		}

		if prime[i] == 0 {
			for j := i * 2; j < MAX; j += i {
				check[j] = 1
				prime[j] = 1
			}
		}
	}

	for i := 2; i < MAX; i++ {
		cnt := 0

		if prime[i] == 0 {
			cnt = 1
		}

		count[i] = count[i-1] + cnt
	}

	for {
		var input int
		inputCount, _ := fmt.Scanf("%d", &input)
		if inputCount != 1 {
			break
		}

		fmt.Println(count[input])
	}
}

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

#define priMAX 1000000

vector<int> sieve_of_eratosthenes(int n) {
	vector<int> primes(n);
	for (int i = 2; i < n; ++i)
		primes[i] = i;
	for (int i = 2; i*i < n; ++i)
	if (primes[i])
		for (int j = i*i; j < n; j+=i)
			primes[j] = 0;
	return primes;
}

int main(){
	vector<int> primes = sieve_of_eratosthenes(priMAX);
	vector<int> all(priMAX);
	int cc = 0;
	for(int i=0; i<priMAX; i++){
		if(primes[i]) cc++;
		all[i] = cc;
	}
	int n;
	while(cin>>n){
		cout<<all[n]<<endl;
	}
	return 0;
}

C++: /*#include <stdio.h>
  int main(){
    int a,b,c,d,n,sum=0;
      while(scanf("%d",&n) != EOF){
       for(a=0;a<10;a++){
          for(b=0;b<10;b++){
             for(c=0;c<10;c++){
                for(d=0;d<10;d++){
                    if(a+b+c+d==n)
                        sum++;
                          }
                            }
                             }
                               }
                                printf("%d\n",sum);
                                 sum=0;
                                   }
return 0;
}*/#include <stdio.h>
  int main(){
   int i,j,n,hantei=0;
   int sum=0;
    while(1){
scanf("%d",&n);
if(n != EOF){
break;
}
    for(i=2;i<=n;i++){
      for(j=2;j*j<=i;j++){
        if(i%j != 0 || i == j){
            hantei += 0;
               }else{
                  hantei += 1;
                    }
}
if(hantei == 0){
sum++;

}
hantei=0;
}
printf("%d\n",sum);
sum=0;
hantei = 0;
}
return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
#define MAX_SIZE 1000100
#define N 999999
int preme[MAX_SIZE];

int main(int argc, char *argv[]) {
	int index = 0;
	for(int i = 0; i < MAX_SIZE; i++)
		if(i % 2)
			preme[i] = 1;
		else {
			preme[i] = 0;
		}
	preme[2] = 1;
	for(int i = 3; i <= 999999; i += 2) {
		if(preme[i]) {
			for(int j = i + i; j <= 999999; j += i)
				preme[j] = 0;
		}
			
	}
	//freopen("data.txt", "r", stdin);
	int n;
	while(~scanf("%d", &n)) {
		long count = 0;
		for(int i = 1; i <= n; i++)
			if(preme[i])
				count++;
		cout << count << endl;
	}
		
}

C++: #include<stdio.h>
#include<string.h> 
#define MAX 10000000

int prime[MAX];
bool isprime[MAX];


int main()
{
	long n;
	int primeSize=0;
	
	while(scanf("%d",&n)!=EOF)
	{
		memset(isprime,1,sizeof(isprime));
		isprime[0]=isprime[1]=0;
		for(int i=2;i<=n;i++)
		{
			if(isprime[i]) prime[++primeSize]=i;
			for(int j=1;j<=primeSize&&i*prime[j]<=n;j++)
			{
				isprime[i*prime[j]]=0;
				if(i%prime[j]==0) break;
			}
		}
			printf("%d\n",primeSize);
	}
}

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

bool is_prime(int n,int r);

int main(void) {
	using namespace std;
	int x;
	int count;
	while (cin >> x) {
		count = 0;
		double r = pow(x, 0.5);
		for (int i = 2; i <= x; i++) {
			if (is_prime(i,r))count++;
		}
		cout << count << endl;
	}
	return 0;
}



bool is_prime(int n,int r) {
	static int flag = 0;
	static int list[78498];
	static int count = 0;
	if (flag == 1) {
		for (int i = 0; i < count; i++) { 
			if (list[i] >r) {
				return true;
			}
			if (n % list[i] == 0) {
				if (n == list[i]) {
					
					return true;
				}
				
				return false;
			}
		}

	}
	flag = 1;
	list[count] = n;		
	count++;
	
	return true;
}

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

int main(){
int unti[100002] = {0};
fill(unti,unti + 100001,0);
for(int n = 2;n < 100001;n++)
{
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 100001;a++)
{
	if((a * n  ) < 100001 ) unti[a * n]++;
}
}
}
int b;
while(cin >> b )
{
int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt ;
	}


}

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

const int maxn=1e6+10;
bool prime[maxn];
int sum[maxn];

void isprime()
{
    memset(prime,true,sizeof(prime));
    for(int i=2;i<=1e3;i++)
    {
        if(prime[i])
        {
            for(int j=i*i;j<1e6;j+=i)
                prime[j]=false;
        }
    }
}

void add()
{
    memset(sum,0,sizeof(sum));
    for(int i=2;i<maxn;i++)
    {
        sum[i]=sum[i-1];
        if(prime[i])
            sum[i]++;
    }
}

int main()
{
    int n;
    isprime();
    add();
    while(scanf("%d",&n)!=EOF)
        printf("%d\n",sum[n]);
    return 0;
}

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

int count_prime( unsigned int const& n )
{
    if ( n <= 0 || 1000000 <= n ) return -1;
    std::vector<bool> memo_prime( n+1, true );
    for ( unsigned int i = 2; i < n; ++i )
    {
        for ( unsigned int j = 2; i*j <= n; ++j )
        {
            memo_prime.at(i*j) = false;
        }
    }
    memo_prime.at(0) = memo_prime.at(1) = false;
    memo_prime.at(2) = true;
    return std::count( memo_prime.begin(), memo_prime.end(), true );
}

int main()
{
    int n;
    while( std::cin >> n )
    {
        std::cout << count_prime(n) << std::endl;
    }
    return 0;
}

C++: #include <stdio.h>

int check_prime(int a)
{
   int c;

   for ( c = 2 ; c <= a-1; c++ )
   {
      if ( a%c == 0 )
        return 0;
   }
      return 1;
}

int main ()
{
    int  n=0,i=0,prime=0,result=0;

   while( scanf("%d",&n) != EOF)
{
 for(i=2;i<=n;i++)
 {

   result = check_prime(i);

   if ( result == 1 )
     prime = prime +1;
 }
 printf("%d",prime);
 printf("\n");
 prime=0;
}
 return 0;
}

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

int MAX = 1000001;
int prime[1000001] = {};

void make_prime(){
  int i, j;

  for (i = 2; i < MAX; i++) {
    prime[i] = 1;
  }

  for (i = 2; i * i < MAX; i++) {
    if (prime[i]){
      for (j = i * 2; j < MAX; j += i) {
        prime[j] = 0;
      }
    }
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  make_prime();
  int i, input, count;

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

  return 0;
}

C++: #include<iostream>
#include<string>
#include<cmath>
//#include<time.h>
using namespace std;

int main()
{
	
	long long int k,p[100000];
	long long int n;
	//time_t time1,time2;
	p[0]=2;
	while(cin>>n){
		//time(&time1);
		if(n<0){
			break;
		}
	k=0;
	int r=(int)sqrt((float)n);
	for(int i=3;i<=r;i++){
		for(int j=0;j<k+1;j++){
			if(i%p[j]==0){
				break;
			}else if(j==k){
				k++;
				//cout<<i<<endl;
				p[k]=i;
			}
		}
	}
	long long int r_k=k;
	for(;r<n;r++){
		for(long int i=0;i<=r_k;i++){
			if(r%p[i]==0){
				break;
			}else if(i==r_k){
				k++;
				//cout<<r<<endl;
			}
		}
	}
	//time(&time2);
	if(k!=0&&k!=1){
		k+=1;
		cout<<k<</*"ツ古t\t"<<difftime(time2,time1)<<"minutes"<<*/endl;
	}else{
		cout<<k<</*"\t\t"<<difftime(time2,time1)<<"minutes"<<*/endl;
	}
	}
}

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

int p[1000000],size;

bool isPrime(int x){
	for(int i=0;p[i]*p[i]<=x;i++){
		if(x % p[i] == 0) return false;
	}
	return true;
}

void mkPrime(int n){
	size = 0;
	p[size++] = 2;
	for(int i=3;i<=n;i+=2){
		if(isPrime(i)){
			p[size++] = i;
		}
	}
}


int main(void){
	mkPrime(1000020);

	int n;	
	while(cin>>n){
		int ans = 0;
		for(int i=0;p[i]<=n;i++){
			ans++;
		}
		printf("%d\n",ans);
	}

	return 0;
}