Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [31]int
	var inputCount, primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		resultArr[inputCount] = primeCount
		if inputCount == 30 {
			break
		}
		primeCount = 0
		inputCount++
	}
	for _, v := range resultArr {
		fmt.Printf("%d\n", v)
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

C++: #include <stdio.h>

int primes[78498], primepis[1000000], num_primes;
int calculated;
int mysqrt(unsigned int x) {
	int a = 0, c = 0, y = 0, i = 0, t = x;
	while (t >>= 1) {
		++i;
	}
	for (i += i & 1; i >= 0; i -= 2) {
		c = (y << 1 | 1) <= x >> i;
		a = a << 1 | c;
		y = y << 1 | c;
		x -= c * y << i;
		/* if(c){
		  x -= y << i;
		} */
		y += c;
	}
	return a;
}
int main() {
	primes[0] = 2;
	primepis[2] = 1;
	calculated = 2;
	num_primes = 1;
	for (unsigned int i = 3; i <= 999999; i += 2) {
		bool is_prime = true;
		int max = (int)(mysqrt(i)) + 1;
		for (int j=1; primes[j] < max && j<num_primes; j++) {
			if (i%primes[j] == 0) {
				is_prime = false;
				break;
			}
		}
		if (is_prime) {
			primes[num_primes++] = i;
			primepis[i] = primepis[i + 1] = primepis[i - 1] + 1;
		}
		else {
			primepis[i] = primepis[i + 1] = primepis[i - 1];
		}
	}
	while (true) {
		int n;
		if (!scanf("%d", &n)) break;
		printf("%d\n", primepis[n]);
	}
}

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

int main(){
  int n;
  int num[1000000]={0};
  num[0]=1;
  num[1]=1;

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

  while(scanf(" %d",&n)!=EOF){
    int cnt=0;
    for(int i=2;i<=n;i++){
      if(num[i]==0){
	cnt++;
      }
    }
    cout << cnt << endl;
  }

  return 0;
}

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

using namespace std;

#define maxn 999999 + 5
typedef long long ll;

int prime[maxn];

void init(){
    for(int i=2;i<maxn-4;i++)
        prime[i] = i % 2;
    prime[2]=1;
    prime[1]=0;
    for(int i=2;i*i<=maxn;i++){
        if(!prime[i])continue;
        for(int j=i;j*i<=maxn;j++)
            prime[i*i]=0;
    }
    for(int i=2;i<=maxn;i++)
        prime[i] += prime[i-1];
}
int main(){
    int n;
    init();
    
    while(~scanf("%d",&n))
        printf("%d",prime[n]);
    return 0;
}

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

int main()
{
   int n;
   int prime[1000000] = {1,1};
   int a=2;
   vector<int> r;
   while (scanf("%d",&n) != EOF)
   {
      int count=0;
      for (int i=a; i<=sqrt(n); i++)
      {
	 if (prime[i] == 0)
	 {
	    for (int j=i*2; j<1000000; j+=i)
	    {
	       prime[j] = 1;
	    }
	 }
	 a=i;
      }
      for (int i=2; i<=n; i++)
      {
	 if (prime[i] == 0)count++;
      }
      r.push_back(count);
   }
   for (int i=0; i<r.size(); i++)
   {
      cout << r[i] << endl;
   }
   return 0;
}

C++: #include<iostream>

using namespace std;

int n;

int main()
{
	while(cin>>n)
	{
		int count = 0;
		bool *flag = new bool[n]();
		for(int i=2;i<=n;++i)
		{
			if (flag[i]==true)
			{
				continue;
			}
			for(int j=i*2; j<n; j+= i)
			{
				flag[j] = true;
			}
		}

		for(int i=2;i<n;i++)
		{
			if(flag[i]==false)
			{
				++count;
			}
		}
		cout<<count<<endl;
	}
}

C++: #include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>

using namespace std;


int main(){
	int n = 0;
	int count;
	bool flag = false;

	while(cin >> n){
		count = 1;
		for(int i = 3; i <= n; i += 2){
			for(int j = 3; j * j <= i; j += 2){
				if(i % j == 0){
					flag = true;
					break;
				}
			}
			if(flag != true){
				count++;
			}
			flag = false;
		}
		cout << count << endl;
	}

	return 0;
}

C++: /*
Volume0-0009
*/
#include <iostream>
#include <stdlib.h>
#include <string.h>

#define N 1000000
#define TRUE (int)(0==0)
#define FALSE !TRUE

using namespace std;

int main(int argc, char *argv[]){
  int f[N];

  //  memset(f, TRUE, N);
  f[0]=FALSE;
  f[1]=FALSE;
  for (int i=2; i<N; i++)
    f[i] = TRUE;

  for (int i=2; i<N; i++){
    if (f[i] == TRUE ) {
      for (int j=i+i; j<N; j+=i){
	f[j] = FALSE;
      }
    }
  }
  int n;
  while (cin >> n) {
    int m = 0;
    for (int i=1; i<=n; i++){
      if (f[i]){
	m++;
      }
    }
    cout << m;
  }
 
  exit(0);
}

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

    int  main()
    {
    	
    	for (int i=0; i<=30; i++)
    	{
    	
        int  N;
        cin  >>  N;
        
        
        int count = 0;
        for (int  i =  1;  i <= N;  ++i)
        {
            bool  isPrime  =  true ;
            for (int  j =  2;  j < i;  ++j)
            {
                if (i  % j ==  0)
                {
                    isPrime  =  false ;
                    break ;
                }
            }
            if (isPrime)
            {
                --N;
                count++;
                
            }
        }
    
        cout << count << endl;
		}
        return  0;
    }

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

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

void sieve()
{
  prime[0] = prime[1] = false;
  for(int i = 2; i <= MAX_N; ++i)
    prime[i] = true;
  for(int i = 2; i <= MAX_N; ++i)
    if(prime[i])
      for(int j = i * 2; j <= MAX_N; j += i)
	prime[j] = false;
}

int is_prime(int n)
{
  return prime[n];
}

int main()
{
  int n, i;
  int ans;
  sieve();
  while(cin >> n){
    ans = 0;
    for(i = 1; i <= n; i++){
      if(is_prime(i)){
	ans++;
      }
    }
    printf("%d\n", ans);
  }
}

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

const int MAX_N = 1000000;

bool sieve[MAX_N];
int num[MAX_N];

int main()
{
  memset(sieve, true, sizeof sieve);

  sieve[0] = sieve[1] = false;
  int n = 0;
  for (int i = 2; i < MAX_N; i++) {
    if (sieve[i]) {
      n++;
      for (int j = 2 * i; j < MAX_N; j += i) {
        sieve[j] = false;
      }
    }
    num[i] = n;
  }

  int a;
  while (scanf("%d", &a) != EOF) {
    printf("%d\n", num[a]);
  }

  return 0;
}

C++: #include <cstdio>
#define MAX 1000

int main(){
	int n;
	bool c[MAX]={true};
	int t[MAX];t[0] = 0;
	for(int i = 2;i < MAX;i++){
		for(int j = i;i*j < MAX;j++){
			c[i*j-1] = true;
		}
	}
	for(int i = 1;i < 15;i++){
		if(c[i])t[i]=t[i-1];
		else t[i] = t[i-1]+1;
	}
	while(scanf("%d", &n)){
		printf("%d\n", t[n-1]);
	}
	return 0;
}

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

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

int main(){
  int n,prime[1000000],key,lf=0;
  prime[0]=2;
  key=1;
  for(int i=3;i<=999999;i+=2)
    {
      for(int j=2;j<=sqrt(i);j++)
	{
	  if(i%j == 0)
	    {
	      lf=1;
	      break;
	    }
	}
      if(lf == 1)
	{
	  lf=0;
	}
      else 
	{
	  prime[key]=i;
	  key++;
	}
    }

  while(cin >> n)
{
  int cou=0;
  for(int i=0;;i++)
    {
      if(prime[i] <= n)
	{
	  cou++;
	}
      else break;
    }

  cout << cou << endl;
 }
}