Go: package main

import (
  "fmt"
  "math"
)

func main() {
  const N = 1000000
  var temp [N+1]bool
  for i:=0; i<N+1; i++ {
    temp[i] = true
  }
  temp[0] = false
  temp[1] = false
  for i:=2; i<int(math.Ceil(math.Sqrt(float64(N+1)))); i++{
    if (temp[i]){
      for j:=i*2; j<N+1; j+=i{
        temp[j] =false
      }
    }
  }
  var a int
  var b int
  for _, err := fmt.Scan(&a); err == nil; _, err = fmt.Scan(&a) {
    b = 0
    for i:=0; i<=a; i++{
      if temp[i] {
        b++
      }
    }
    fmt.Println(b)
  }
}

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

/*void judge(int n){
	bool arr[1000003];
	for(int i = 2; i < 1000003; i++) arr[i] = true;
}
*/

int main(){
	bool arr[1000003];
	int n,count = 0;
	cin >> n;
	for(int i = 2; i < 1000003; i++) arr[i] = true;

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

	cout << count << "\n";
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
    vector<int> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;

      v[0]=false;
      v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]==true){
        for(int j = i;j<MAX;j=j*j){
         v[i]=false;
       }
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())return 0;
      cout << v[a]<<endl;
    }
}

C++: #include <iostream>

using namespace std;

int main()
{
    long kazu;
    
    while (cin>>kazu)
    {
        int sosuu=0,kari;
        
        for (int i=1; i<=kazu; i++)
        {
            kari=0;
            
            for (int j=1; j<=i; j++)
            {
                
                if (i%j==0)
                    kari++;
                
            }
            
            if (kari==2)
                sosuu++;
            
        }
        
        
        cout<<sosuu<<endl;
    }
    
}

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 <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((*p)*(*p)>i)break;
			if(i%*p==0){
				isprime=false;
				break;
			}
		}
		if(isprime){
			prime.push_back(i);
		}
	}
}
int main(){
	int n;
	init();
	while(cin>>n){
		cout<<upper_bound(prime.begin(),prime.end(),n)-prime.begin()<<endl;
	}
	return 0;
}

C++: import java.util.*;

class Prime2 {
    public static void main(String[] args) {
      
        Scanner scan = new Scanner(System.in);
        int[] x = new int[30];
        int t=0,j,count=0;
        
        
        while(scan.hasNextInt()){
        	count = 0;
			int lim = scan.nextInt();
        	int ptr = 0; //?????????????´???°?????°
        	int[] prime = new int[500000]; //?´???°???????´?????????????
        	
        	if(lim >= 2){
        		prime[ptr++] = 2; 
        		count++;
        	}
        	if(lim >= 3){
				prime[ptr++] = 3; 
				count++;
			}
			
        	for (int n = 5; n <= lim; n += 2) { 
        	    boolean wflag = false; 
        	    for (int i = 1; prime[i] * prime[i] <= n; i++) {
              
            	    if (0 == n % prime[i]) {
                    	wflag = true;
                    	break;
                	}
            	}
            	if (!wflag) { 
                	prime[ptr++] = n; 
                	count++; 
            	}
        	}
        	x[t] = count;
        	t++;
        	
		}
        	for (int i : x)  
            	System.out.println(i);
    }
}

C++: /*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int prime(int a)
{
	if(a<2)
	return 1;

	for(int i=2 ; (i*i)<=a ; i++)
	{
		if(a%i==0)
		return 0;
	}
	
	return 1;
}

int main()
{
	int a;
	int pm[200000];
	int z=0;
	forin(i,2,1000000)
	{
		if(prime(i)==1)
		{
			pm[z]=i;
			z++;
		}
	}
	
	
	while(scanf("%d",&a)!=EOF)
	{
		forin(i,0,z)
		{
			//debugdd(pm[i],a);
			if(pm[i]>a)
			{
				printf("%d\n",i);
				break;		
			}
		}
	}
	return 0;
}

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

int main(){
        int prime[999999];
        bool is_prime[1000000];
        int p =0;
        int n ;
        int i;
        while(cin >> n){
        for(i=0;i<=n;i++) is_prime[i] = true;
        is_prime[0] = is_prime[1] = false;
        for(i=2;i<=n;i++){
                if(is_prime[i]){
                        prime[p++] = i;
                        for(int j=2*i;j<=n;j+=i) is_prime[j] = false;
                }
        }
        cout << p << endl;
        p = 0;
        }
return 0;
}
[tebora@tebora cpp]$ cat  pr.cpp
#include <iostream>
using namespace std;

int main(){
        int prime[999999];
        bool is_prime[1000000];
        int p =0;
        int n ;
        int i;
        while(cin >> n){
        for(i=0;i<=n;i++) is_prime[i] = true;
        is_prime[0] = is_prime[1] = false;
        for(i=2;i<=n;i++){
                if(is_prime[i]){
                        prime[p++] = i;
                        for(int j=2*i;j<=n;j+=i) is_prime[j] = false;
                }
        }
        cout << p << endl;
        p = 0;
        }
return 0;
}

C++: #include <iostream>
using namespace std;
bool t[999999] = {false};
int main()
{
	int n, c, i, j;
	t[0] = true;
	for (i = 2; i <= 999999; i++)
	{
		if (!t[i-1])
		{
			for (j = i+i; j < 999999; j+=i)
				t[j-1] = true;
		}
	}
	while (cin >> n)
	{
		if (cin.eof()) break;
		for (i = c = 0; i < n; i++)
			if (!t[i]) c++;
		cout << c << endl;
	}
}