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<math.h>

/*??????????????¨?????¢??°       */
/*????????????0????????\????????¨???*/
void print_rist(char *rist, int num){
	int i = 2;
	
	while(i <= num) {
		if (rist[i] != 0) {
			printf("%d ", i);
		}
		i++;
	}
	printf("\n");
}


main(){
	char rist[1000001];
	int i, j;
	int input_num = 0;
	int count;
	int ans;
	
	/*??????????????§????´???°????±???????????????\???*/
	for(j = 0; j < 30; j++) {
		scanf("%d", &input_num);
		if (input_num == EOF) {
			break;
		}
		/*??¢?´¢??????????????????*/
		for (i = 1; i <= input_num; i++) {
			rist[i] = 1;
		}	
		rist[i] = 0;
		rist[1] = 0;
		/*?´???°??????????????????*/
		count = 2;
		while((count * count) <= input_num) {	/*???input_num??????????????§*/
			i = 2;
			/*count??\??????count????????°??????????????¨???*/
			while((i * count) <= input_num) {
				rist[i * count] = 0;
				i++;
			}
			count++;
			/*?¬????count?????????*/
			while(rist[count] != 1) {
				count++;
			}
			
		}
		
		ans = 0;
		for (i = 1; i <= input_num; i++) {
			if (rist[i] == 1) {
				ans++;
			}
		}
		printf("%d\n", ans);
		//print_rist(rist, input_num);
	}
	return 0;
}

C++: #include <stdio.h>

int main(void) {

  int n;
  int num;
  int i,flag,count;

  while(scanf("%d",&n)!=EOF) {

    count=0;

    for(num=1;num<=n;num++) {

      flag=1;

      for(i=2;i<num;i++) {
	if(num%i==0) {
	  flag=0;
	  break;
	}
      }
      
      if(num==1) flag=0;

      if(flag==1) { 
	count++;
      }
    }

    printf("%d\n",count);

  }

  return 0;
}

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>

using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;

bool dp[10000100];

int main()
{
	int N;
	while (cin >> N){
		long ans(0);
		dp[0] = dp[1] = true;
		for (int i = 2; i <= N*N; ++i){
			if (!dp[i]){
				for (int j = 2*i; j <= N; j += i)
					dp[j] = true;
			}
		}
		for (int i = 2; i <= N; ++i){
			ans += !dp[i];
		}
		cout << ans << endl;
	}
}

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

int main(){
	int num, cou, i, j, flag;
	
	while(cin >>num){
		cou = 0;
		for(i = 3; i < num; i+= 2, flag = 0){
			for(j = 3; j < sqrt(num); j += 2){
				if(i % j == 0){
					flag = 1;
					break;
				}
			}
			if(flag == 0) cou++;
		}
		cout <<cou + 2<<endl;
	}
	
	return 0;
}

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

int main(){
	int m=0,n;
	cin>>n;
    for(int i=1;i<=n;i++){
    	int s=0;
    	if(i==1)s=1;
    	if(i>3){
    		for(int j=2;j<=sqrt(i);j++){
    			if(i%j==0)s=1;
    		}
    	}
    	if(s==0)m++;
    }
	cout<<m<<endl;
	return 0;
}

C++: #include <stdio.h>

int main(){
	int sosuu[] = { 2, 3, 5 }, i, x, y = 3,n=0,z;
	
	while (scanf("%d", &n)!=EOF){
		z = 0; 
		for (i = 3; i < n + 1; i += 2){
			for (x = 0; x < y; x++){
				if (i % sosuu[x] == 0)break;
				if (x + 1 == y){ sosuu[y] = i, y++;}
			}
		}
		for (i = 0; i < y; i++){ if (sosuu[i] > n)break; z++; }
		printf("%d\n", z);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int tmp;
	while (cin >> tmp)
	{
		vector<int> prime;

		for (int i(2); i <= tmp; ++i)
		{
			for (vector<int>::iterator i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2)
			{
				if ((i % *i2) == 0)
				{
					goto nx;
				}
			}

			prime.push_back(i);
		nx:;
		}

		cout << prime.size() << endl;

		prime.clear();
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

const int MAX = 1000000;
int N;

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

    vector<bool> is_prime(MAX,true);
    vector<int> prime(MAX,0);
    is_prime[0] = is_prime[1] = false;
    prime[0] = prime[1] = 0;
    int p = 0;
    for(int i = 2; i < MAX; ++i){
        if(is_prime[i]){
            for(int j = i*2; j < MAX; j += i) is_prime[j] = false;
        }
    }

    for(int i = 1; i < MAX; ++i){
        prime[i] = prime[i-1] + is_prime[i];
    }

    while(cin >> N){
        cout << prime[N] << '\n';
    }
    return 0;
}

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;
	}
}