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 <bits/stdc++.h> 
using namespace std; 
typedef long long ll;




int main(){


	int Nmax = 1000000;
	bool isp[Nmax]={};
	int count[Nmax]={};

	isp[2] = true;
	for(int i=3;i<Nmax;i+=2){
		isp[i] = true;
	}

	for(int i=3;i<Nmax;i+=2){
		if(isp[i]){
			int j = i*2;
			while(j<Nmax){
				isp[j] = false;
				j += i;
			}
		}
	}

	for(int i=1;i<Nmax;i++){
		count[i] = count[i-1] + isp[i];
	}

	int n;
	while(cin >> n){
		cout << count[n] << endl;
	}

}

C++: #include<stdio.h>

int main(void){

	int sosuu[1000000],kazu,n,i,j;

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

		kazu=n-1;

		for(i=2;i<=n;i++){
			sosuu[i]=1;
		}
		sosuu[0]=0;sosuu[1]=0;

		for(i=2;i<=n;i++){
			if(sosuu[i]==1){
				for(j=i*2;j<=n;j+=i){
					if(sosuu[j]==1){
						kazu--;
						sosuu[j]=0;
					}
				}
			}
		}

		printf("%d\n",kazu);
		
	}

	return 0;
}

C++: #include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> prime;
void init(){
	for(int i=2;i<999999;i++){
		bool isprime=true;
		for(vector<int>::iterator p(prime.begin());p!=prime.end();p++){
			if(i%*p==0){
				isprime=false;
				break;
			}
		}
		if(isprime){
			prime.push_back(i);
		}
	}
}
int main(){
	int n;
	init();
	while(cin>>n){
		cout<<lower_bound(prime.begin(),prime.end(),n)-prime.begin()+1<<endl;
	}
	return 0;
}

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

#define N 1000000L
bool num[N];

void furui() {
	long int i;
	int divide;
	int rt = 1000;
	for (i = 0L; i < N; i++) {
		num[i] = true;
	}
	num[0] = false;
	num[1] = false;
	for (divide = 2; divide <= rt; divide++) {
		if (num[divide] == false) continue;
		for (i = (long int)divide; i < N; i += divide) {
			num[i] = false;
		}
		num[divide] = true;
	}
}

int main(void) {
	int c, i, j;
	long int k;
	char buf[7];
	long int n;
	long int count;

	furui();

	for (j = 0; j < 30; j++) {
		for (i = 0; ; i++) {
			c = getchar();
			if (c == EOF || c == '\n') {
				buf[i] = '\0';
				break;
			}
			buf[i] = c;
		}
		n = atol(buf);
		count = 0L;
		for (k = 1L; k <= n; k++) {
			if (num[k] == true) count++;
		}
		std::cout << count << std::endl;
		if (c == EOF) break;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a,x,i;
	while((scanf("%d",&a))!=EOF){
		x=0;
		for(i=0;i<a;i++){
			if((a-i)==1){
			}
			else if((a-i)%2!=0&&(a-i)%3!=0&&(a-i)%5!=0&&(a-i)%7!=0){
				x++;
			}
			else if((a-i)==2||(a-i)==3||(a-i)==5||(a-i)==7){
				x++;
			}
		}
		printf("%d\n",x);
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
int cnt,n,prime[1000000];
using namespace std;

void getprime()
{
	/*int tt=0,flag;
	prime[tt++]=2;
	for(int i=3;i<=1000000;i++) 
	{
		flag=1;
		for(int j=0;prime[j]*prime[j]<=i;j++)
		{
			if(i%prime[j]==0)
			{	
			    flag=0;
		     	break;
			}
		}
		if(flag==1) prime[tt++]=i;
	}*/
	memset(prime,0,sizeof(prime));  
    for(int i = 2; i<=1000000; i++)  
    {  
        if (!prime[i]) prime[++prime[0]] = i;  
        for(int j = 1;j<=prime[0] &&prime[j] < 1000000/i;j++ )  
        {  
            prime[prime[j]*i] = 1;  
            if(i%prime[j]==0) break;  
        }  
    } 
}

int main()
{	getprime();
	while(scanf("%d",&n))
	{
       for(int i=1;;i++){
       	if(prime[i]>n){
       		printf("%d\n",i-1);
       		break; 
		   }
	   }
    }
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main(){
	int i,j,n;
	static bool prime[1000001];
	for (i = 3; i <= 1000000; i += 2){
		prime[i] = true;
	}
	prime[2] = true;

	for (i = 3; i <= 1000; i += 2){
		if (prime[i] == 1){
			for (j = 3; j <= 1000000 / i; j += 2){
				prime[i * j] = false;
			}
		}
	}
	while(cin >> n && n){
		int count = 0;
		for(i=2;i<=n;i++){
			if(prime[i] == true) count++;
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <stdint.h>
using namespace std;

int sieve(int x)
{
  int ret = 0;
  vector<bool> v(x + 1, true);
  for (int i = 2; i <= x; i++) {
    if (v[i]) {
      ret++;
      for (int j = i + i; j <= x; j += i) {
        v[j] = false;
      }
    }
  }

  return ret;
}

int main()
{
  for (int n; cin >> n; ) {
    cout << sieve(n) << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
bool isPrime(long a) {
	if (a < 2) return false;
	long i;
	for (i = 2; i * i <= a; i++) {
		if (a % i == 0) return false;
	}
	return true;
}
signed main() {
	int Prime[1000000] = {};
	for (int i = 0; i < 1000000; i++) {
		if (isPrime(i)) {
			Prime[i] = 1;
		}
	}
	for (int i = 1; i < 1000000; i++) {
		Prime[i] += Prime[i - 1];
	}
	int n;
	while (cin >> n) {
		cout << Prime[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<math.h>
using namespace std;
int tim(int n)
{
	int i,s=0;
	int *a;
	a=new int [n+1];
	for(i=1;i<=n;i++)
	a[i]=1;
	for(i=2;i*i<=n;i++)
	{
		if(a[i]!=0)
		for(int j=i*i;j<=n;j=j+i)
		a[j]=0;
	}
	for(i=2;i<=n;i++)
	if(a[i]==1)
	{
	s=s+1;
   } 
	return s;
}
int main()
{
	int n,i=1;
	do
	{
		int k;
		cin>>n;
		if(n<2)
		k=0;
		else
		k=tim(n);
		cout<<k;
		cout<<endl;
	}
	while(1);
}

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

using namespace std;


void initialize(vector<int> &search_list, int num);

void era(vector<int> &search_list, vector<int> &prime_list, int num);


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

  int num;

  while (cin >> num){
    vector<int> search_list, prime_list;
    initialize(search_list, num);
    era(search_list, prime_list, num);
    cout << prime_list.size() << endl;
  }
  return 0;
}

void initialize(vector<int> &search_list, int num){
  for (int i=2; i<=num; ++i){
    search_list.push_back(i);
  }
  return;
}

void era(vector<int> &search_list, vector<int> &prime_list, int num){
  do{
    vector<int>::iterator it = search_list.begin();
    int count = 1;
    int N = *it;
    prime_list.push_back(*it);
    while ((N*count) <= num){
      it = find(search_list.begin(), search_list.end(), (N*count));
      if (it != search_list.end()){
        it = search_list.erase(it);
      }
      ++count;
    }
  } while (!search_list.empty());
}

C++: 
#include<stdio.h>
int main()
{
    int a,N,M,sum=0,i,j,count=0,flag=0;
    while (scanf ("%d",&M)!=EOF )
        {
            for(i=2;i<=M;i++)
            {
                flag=0;

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

                    }


            }
                  printf("%d\n",count);
                  count=0;
        }

    return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
bool F[1000000]={};


int main(){

	for(int i=2;i<1000000;i++)
	for(int j=2;j*j<=i;j++){
		if(i%j==0){F[i]=false;break;}
		else F[i]=true;
	}
	F[2]=true;F[3]=true;
	int N;
	while(cin>>N){
		int c=0;
		for(int i=0;i<=N;i++){
			if(F[i]==true){c++;//cout<<i<<endl;
			}}

		cout<<c<<endl;
	}
	return 0;

}