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

int main(void){
    int n;
    int cnt;
    int prm;

    while (scanf("%d", &n)!= EOF){
        cnt = 0;
        for(int i=2; i<=n; i++){
            prm=1;
            for (int j=2; j*j<= i; j++){
                if (i%j==0){
                    prm=0;
                    break;
                }
            }
            cnt+=prm;
        }
        printf("%d\n", cnt);
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(int argv,int* argv[]){
unsigned x[30];
int count=0;
for(int i=0;i<argv;i++){
cin>>x[i];
}
for(int i=0;i<argv;i++){
for(int j=1;j<x[i];j++){
if(x[i]%j!=0)
count++;
}
cout<<count<<endl;
count=0;
}
return 0;
}

C++: #include<iostream>
#include<vector>
int main(){
	int n;
	while(std::cin>>n){
		int ans=0;
		std::vector<int> vec(n+1);
		for(int i=0;i<=n;i++)vec[i]=1;
		vec[0]=vec[1]=0;
		for(int i=2;i<=n;i++){
			if(vec[i] == 1){
				ans++;
				for(int j = 2 * i ; j <= n ; j += i){
					vec[j]=0;
				}
			}
		}
		std::cout<<ans<<std::endl;
	}

	return 0;
}

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

using namespace std;

#define NUM_LIMIT 1000000   // numbers < NUM_LIMIT

int getNumOfPrimes(bitset<NUM_LIMIT> &isPrime, int last_limit, int limit){
    int cnt = 0;
    for (int i = 2; i <= limit; i++){
        if (!isPrime[i]) continue;  // skip non prime numbers
        cnt ++;
        // cross out the multiples of the number
        for (int j = max(2.0,ceil((double)last_limit/i)); i*j <= limit; j++){
            isPrime[i*j] = 0;
        }
    }
    return cnt;
}

int main(){
    //ifstream cin("input.txt");
    bitset<NUM_LIMIT> isPrime;
    isPrime.set();  // set all bits to 1
    
    // input data
    int number;
    int max_num = 0;
    while(cin >> number){
        int cnt = 0;
        if (number > max_num){
            cnt = getNumOfPrimes(isPrime, max_num+1, number);
            max_num = number;
        } else {
            cnt = getNumOfPrimes(isPrime, number+1, number);
        }
        cout << cnt << endl;
    }
    return 0;
}

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

int main(void){
  int n;
  while(cin >> n){
    if(n < 3){
      if(n < 2){
	cout << 0 << endl;
      }else{
	cout << 1 << endl;
      }
    }
    for(int i = 3; i <= n; i += 2){
      bool flag = true;
      for(int j = 3; j <= sqrt(i); j += 2){
	if(i % j == 0){
	  flag = false;
	}
      }
      if(flag)
	ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#define MAX_V 1000000
int prime[MAX_V + 1];
int sum[MAX_V + 1];
int main(){
  int n, i, k;
  /*??¨????????????????????????*/
  prime[0]=prime[1]=0;
  for(i = 2;i <= MAX_V;i++){
    prime[i] = 1;
  }
  for(i=2;i*i<=MAX_V;i++){
    if(prime[i]){
      for(k = 2*i;k <= MAX_V;k += i){
        prime[k] = 0;
      }
    }
  }
  /*?´???????*/
  sum[0] = 0;
  for(i = 0;i < MAX_V;i++){
    sum[i+1] = sum[i]+prime[i+1];
  }
  /*?´???°?????°???????????????*/
  while(scanf("%d", &n) == 1){
    printf("%d\n", sum[n]);
  }
  printf("%d %d %d\n", n,prime[MAX_V], sum[MAX_V]);
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
constexpr int MAX_N = int(1e6) + 5;

uint64_t flag[MAX_N];


void set_f(uint64_t i){
    flag[i>>6] &= ~(1ULL<<(i&((1ULL<<6)-1)));
}

bool get_f(uint64_t i){
    return ((flag[i>>6]>>(i&((1ULL<<6)-1)))&1);
}

void sieve(const int64_t n){
    const uint64_t siz = n/2, sqrtN = ceil(sqrt(n)+0.1)/2;
    fill(flag, flag+(siz>>6)+1, -1);
    for(uint64_t i=1ULL; i<=sqrtN; ++i){
        if(get_f(i)){
            const uint64_t p = 2*i+1;
            for(uint64_t j = 2*i*(i+1); j<=siz; j+=p){
                set_f(j);
            }
        }
    }
}

bool isPrime(int n){
    if(n == 2) return true;
    else return n&1 && get_f(n/2);
}

int cum[MAX_N]{};

int main() {
    sieve(MAX_N);
    for(int i=2;i<MAX_N;i++){
        if(isPrime(i))cum[i]++;
        cum[i] += cum[i-1];
    }
    int n;
    while(cin >> n){
        cout << cum[n] << endl;
    }
    return 0;
}

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

bool Eratos[1000000];

int main()
{
	Eratos[0] = Eratos[1] = false;
	for (int i = 0; i < 1000000; i++){
		Eratos[i] = true;
	}
	for (int i = 2; i < 1000; i++) {
		if (Eratos[i]) {
			for (int j = 2 * i; j < 1000000; j += i) {
				Eratos[j] = false;
			}
		}
	}
	int n,res;
	while (scanf("%d", &n)) {
		res = 0;
		for (int i = 0; i < n; i++) {
			if (Eratos[i])
				res++;
		}
		printf("%d\n",res);
	}
	return 0;
}

C++: #include <stdio.h>
#include <cmath>

using namespace std;

#define REP(a, i, n) for (int i = a; i <= n; ++i)

bool isPrime(int n) {
    if (n == 1) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    if (n == 3) return true;
    if (n % 3 == 0) return false;

    for (int i = 5; i <= sqrt(n); i += 2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

//  n よりも小さい素数の数は何個存在するか
int main() {

    int n = 0; // 999,999
    while(scanf("%d", &n) != EOF) {
        int cnt = 0;
        REP(1, i, n) {
            if (isPrime(i)) cnt++;
        }

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

    return 0;
}

C++: #include <iostream>
#include <bitset>

using namespace std;

int main() {
  bitset<1000000> primes;
  int i, j, n, ans;
  while (cin >> n) {
    primes.reset();
    for (i = 2; i <= n; i++)
      if (primes[i] == false)
	for (j = i + i; j <= n; j += i)
	  primes[j] = true;
    cout << (n == 0 ? 0 : n - primes.count() - 1) << endl;
 }
  return 0;
}

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

int main() {
	std::vector<bool> isPrime(1000000, true);
	std::vector<int> numP(1000000, 0);

	isPrime[0] = false;
	isPrime[1] = false;

	for (int i = 2; i < 1000000; i++) {
		if (isPrime[i]) {
			numP[i] = numP[i - 1] + 1;
			for (int x = 2; i*x < 1000000; x++) {
				isPrime[i*x] = false;
			}
		}
		else {
			numP[i] = numP[i - 1];
		}
	}

	int input;
	while (std::cin >> input) {
		std::cout << numP[input] << std::endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,count=0;
  while(scanf("%d",&n)!=EOF){
    if(n==0 || n==1){
      return 0;
    }
    int data[n+1];
    for(int i=2;i<=n;i++){
      data[i]=0;
    }
    for(int i=2;i<=n;i++){
      if(data[i]!=-1){
	count++;
	for(int j=i;j<=n;j+=i){
	  if(data[j]!=-1){
	  data[j]=-1;
	  }
	}
      }
    }
    cout << count << endl;
    count=0;
  }
  return(0);
}

C++: #include<stdio.h>
#include<math.h>
int main(void) {
	int prime[1000000] = { 0 }, n, sum = 0;;
	prime[1] = 1;
	while (scanf("%d", &n) != EOF) {
		for (size_t i = 2; i <= sqrt(n); i++)
		{
			if (prime[i] == 0)
			{
				for (size_t t = i + 1; t <= n; t++)
				{
					if (t%i == 0)prime[t] = 1;
				}
			}
		}
		for (size_t i = 2; i <= n; i++)
		{
			if (prime[i] == 0)sum++;
		}
		printf("%d\n", sum);
		sum = 0;
	}
	return 0;
}

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

void cnt(int i) {
	int j,k,l,m;
	l=0;
	m=0;
	for(j=1;j<=i;j++){
		for(k=1;k<=sqrt(j)+1;k++){
			if(j%k == 0){
				l++;
			}
		}
		if(l == 2){
			m++;
		}
		l=0;
	}
	printf("%d\n",m);
}

int main(void){
	int i;
	while (scanf("%d", &i) != EOF){
		cnt(i);
	}
}