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 <cmath>
#define rep(i,N) for(int i = 0; i<(int)(N); i++)
#define REP(i,k,N) for(int i = k; i<(int)(N); i++)
using namespace std;
const int MAX_N = 10000010;
bool d[MAX_N];
int main(){
        int n;
        while(cin >> n) {
                rep(i,MAX_N) d[i]=true;
                for(int i = 2; i< sqrt(n+1); i++) {
                        if(d[i]) {
                                for(int j = 2; i*j<n+1; j++) {
                                        d[i*j]=false;
                                }
                        }
                }
                int ans = 0;
                REP(i,2,n+1){
                        if(d[i]) ans++;
                }
                cout << ans << endl;
        }

        return 0;
}

C++: main(){int i,j,n;char p[1000000];while(scanf("%d",&n)!=-1){for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];printf("%d\n",j);}}

C++: #pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	//memset(vis, 0, sizeof(vis));
	//memset(prime, 0, sizeof(prime));
	fill(prime, prime + MAX, 1);
	prime[0] = prime[1] = 0;
	for (int i = 2; i*i <= MAX; i++){
		if (prime[i]){

			for (int j = i + i; j <= MAX; j += i){

				prime[j] = 0;
			}
		}
	}
	int sum = 0;
	for (int i = 0; i <= MAX; i++){
		if (prime[i]){
			sum++;
		}
		amount[i] = sum;
	}
	int n;
	while (cin >> n){
		cout << amount[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<math.h>
main(){int i,j,n,p[1000000];std::cin>>n;for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)if(p[i])for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];std::cout<<j<<"\n";}

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[100000];
	int data[100000];
	int count;
	c[0]=c[1]=0;
	for(i=2;i<100000;i++){
		c[i]=1;
	}

	while((scanf("%d",&n)!=EOF)&&(n!=0)){
		
		count=0;
		for(i=0;i*i<=n;i++){
			data[i]=count;
			if(c[i]==1){
				count++;
				for(j=i+1;j<=n;j++){
					if(j%i==0){
						c[j]=0;
					}
				}
			}
		}

		printf("%d",data[n]);
	}
	return 0;
}

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

using namespace std;

int main() {
  int n;
  
  while(1) {
    cin >> n;
    if(cin.eof()) {
      break;
    }
    int m = (int)sqrt(n);
    
    vector<bool> h(n+1, true);
    h[0] = false;
    h[1] = false;
    
    for(int i = 2; i <= m; i++) {
      if(h.at(i)) {
	for(int s = 2; s*i < h.size(); s++) {
	  if(h.at(s*i))
	    h[s*i] = false;
	}
      }
    }
    
    int ans=0;
    for(auto f : h) {
      if(f)
	ans++;
    }
    cout << ans << endl;
  }
  
  return 0;
}

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

bool a[1000000] ;
int main(){
    a[0] = 1 ;
    a[1] = 1 ;
    vector<int> v ;
    for(int i=2;i<1000000/2;i++){
        if ( a[i] == 0 ){
            v.push_back(i);
            for(int j=i+i;j<1000000;j+=i){
                a[j] = 1 ;
            }
        }
    }

    int x ;
    while(cin >> x){
        long long c = 0 ;
        for(int i=0;i<v.size();i++){
            if ( v[i] > x ) break;
            c++;
        }
        cout << c << endl;
    }



    return 0 ;
}

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

int prime[1000000];


bool isPrime(int n) {
  int x = (int)sqrt((float)n);
  for (int i = 3; i <= x; i += 2) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}


void get_prime(int max_num) {
  int primecount = 1;
  prime[2] = primecount;
  for (int i = 3; i <= max_num; i += 2) {
    if (isPrime(i))
      prime[i] = ++primecount;
    else
      prime[i] = primecount;
  }
}


int main () {
  int ns[31];
  int i = 0, max_num;
  while (std::cin >> ns[i]) {
    max_num = std::max(max_num, ns[i]);
    if (ns[i] % 2 == 0)
      ns[i] --;
    i ++;
  }
  get_prime(max_num);
  for (int j = 0; j < i; j ++) {
    std::cout << prime[ns[j]] << std::endl;
  }
  return 0;
}

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

using namespace std;

int main() {
	vector<int> prime_num{ 2, 3 };
	int n;

	while (cin >> n){
		int result;
		if (n <= 1) {
			result = 0;
		}
		else if (n == 2){
			result = 1;
		}
		else if (n < prime_num.back()){
			result = count_if(prime_num.begin(), prime_num.end(), [n](int a){return a <= n; });
		}
		else {
			for (int i = prime_num.back() + 2; i <= n; i += 2) {
				int temp = static_cast<int>( sqrt(i));
				auto it = find_if(prime_num.begin(), prime_num.end(), [temp](int a){return a > temp; });
				if (all_of(prime_num.begin(), it, [i](int a){return (i % a) != 0; })) {
					prime_num.push_back(i);
				}
			}
			result = prime_num.size();
		}

		cout << result << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int a,o=0;
    bool n[1000000];
    for(int i=2;i<=999999;i++){
        n[i]=true;
    }
    n[0]=n[1]=false;
        for( int j=2;j*j<=999999;j++){
            if(n[j]){
                for(int k=j*2;k<=999999;k+=j){
                n[k]=false;
                }
            }
        }
        while(cin>>a){
    for(int k=2;k<=a;k++) if(n[k]) o++;
    cout<<o<<endl;
    o=0;
        }
}

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

int main(void) {

  int x;
  int count_cin = 0;
  while(true){
    cin >> x ;
    count_cin++;

    if(count_cin == 30) break;


    bool array[max_n];

    for(int i = 0; i < max_n; i++) {
      array[i] = true;
    }

    array[0] = false;
    array[1] = false;
    for(int i = 2; i < max_n; i++) {
      for(int j = 2; j < max_n; j++) {
        if(i * j > max_n) break;
        array[i * j] = false;
      }
    }

    int count_sosu = 0;

    for(int i = 0; i <= x; i++) {
      if(array[i] == true) count_sosu++;
    }

    cout << count_sosu << endl;
  }
  return 0;
}

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

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