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>
#define N 1000000

int main() {
	int ipt;
	int root;
	int cnt = 0;
	int A[N];
	for (int i = 1; i <= N; i++) {
		A[i] = i;
	}
	for (int pos = 2; pos*pos <= N; pos++) {
		root = A[pos];
		if (!root)continue;
		for (int k = 2; k*root <= N; k++) {
			A[k*root] = 0;
		}
	}

	while(scanf("%d",&ipt)==1) {
		for (int i = 2; i <= ipt; i++) {
			if (A[i] != 0)cnt++;
		}
		printf("%d\n", cnt);
		cnt = 0;
	}

	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

const int kSieveSize = 1000001;
bool sieve[kSieveSize] = {true, true};

int main()
{
  vector<int> primes;
  primes.reserve(kSieveSize);
  for (int i = 2; i * i < kSieveSize; ++i){
    if (sieve[i]) continue;
    primes.push_back(i);
    for (int j = i * i; j < kSieveSize; j += i){
      sieve[j] = true;
    }
  }
  for (int n; ~scanf("%d", &n); ){
    printf("%d\n", upper_bound(primes.begin(), primes.end(), n) - primes.begin());
  }

  return (0);
}

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

using namespace std;

int main() {

	int n;
	int i,j;

	while (cin >> n) {
		int counter = 1;

		for (i = 3; i <= n; i = i + 2) {
			int kari = 1;
			for (j = 3; j < i; j=j+2) {
				if ((j % 3 == 0 && j != 3) || (j % 5 == 0 && j != 5) || (j % 7 == 0 && j != 7) || (j % 11 == 0 && j != 11) || (j % 13 == 0 && j != 13) || (j % 17 == 0 && j != 17) ||
					(j % 19 == 0 && j != 19) || (j % 23 == 0 && j != 23)) {
					continue;
				} else if (i % j == 0) {
					kari = 0;
					break;
				}
			}

			if (kari != 0) {
				counter++;
			}
		}

		cout << counter << endl;
	}

	return 0;
}

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

vector<int> Prime;
void PrimeCalc() {
  bool IsPrime[1000000];
  for(int i=0; i<1000000; i++) {
    IsPrime[i] = true;
  }
  IsPrime[0] = IsPrime[1] = false;
  for (int i=2; i<1000000; i++) {
    if (IsPrime[i]) {
      Prime.push_back(i);
      for (int j=2*i; j<1000000; j+=i) {
        IsPrime[j] = false;
      }
    }
  }
}

void solve() {
  PrimeCalc();
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int i=0; i<Prime.size(); i++) {
      if (Prime[i]<=n) {
        ans++;
      } else {
        break;
      }
    }
    cout << ans << endl;
  }
}

int main() {
  solve();
  return 0;
}

C++: #include <stdio.h>

int IsPrime(int n);

int main(void){
    int n, cnt, minID, min=1;
    int list[100000];

    cnt=0;
    for (long i=2; i<1000000; i++){
	//    printf("%d %d\n",i, cnt);
        if (i%10==0) list[i/10] = cnt;
        cnt += IsPrime(i);
    }
	printf("input : ");
    while (scanf("%d", &n) && n!=EOF){
        cnt = list[n/10];
        for (long i=1; i<n%10; i++){
            cnt += IsPrime(i);
        }
        printf("%d\n", cnt);
    }
    return 0;
}

int IsPrime(int n){
    int i;

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

C++: #include <stdio.h>

int sieve(int n)
{
	char prime[999999];
	int i, j;
	int p;
	
	for (i = 0; i <= n + 1; i++){
		prime[i] = 1;
	}
	prime[0] = prime[1] = 0;
	
	for (i = 2; i <= n + 1; i++){
		if (prime[i]){
			for (j = 2 * i; j <= n; j += i){
				prime[j] = 0;
			}
		}
	}
	for (i = 0, p = 0;i <= n; i++){
		if (prime[i] == 1){
			p++;
		}
	}
	
	return (p);
}

int main(void)
{
	int num;
	int ans;
	
	while (scanf("%d", &num) != EOF){
		ans = sieve(num);
		
		printf("%d\n", ans);
	}
	
	return (0);
}

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

using namespace std;

int main() {
  int n;
  
  while(!cin.eof()) {
    cin >> n;
    list<int> search_list(n-1);
    list<int> prime_number;
    while(n!=1) {
      if(n%2 != 0) 
	search_list.push_front(n);
      n--;
    }
    
    while(!search_list.empty()) {
      int m = search_list.front();
      prime_number.push_back(m);
      search_list.pop_front();
      list<int>::iterator it = search_list.begin();
      while(it!=search_list.end()) {
	if((*it % m) == 0){
	  it = search_list.erase(it);
	  continue;
	}
	it++;
      }				   
    }
    cout << prime_number.size()+1 << endl;
    prime_number.clear();
    search_list.clear();
  }
}

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

using namespace std;

int furui(int N){
  int i;
  int count=0;
  int array[1000000];
  array[0]=false;
  array[1]=false;
    
  for(i=2;i<=N;i++){
    array[i]=true;
  }

  for(i=2;i*i<=N;i++){
    if(array[i]==true)for(int j=i*i;j<=N;j+=i){
	array[j]=false;
      }
  }

  for(i=2;i<=N;i++){
    if(array[i]==true)count++;
  }

  return count;
}

int main(){
  int cnt=0,n;
  while(cnt<30){
    cnt++;
    cin >> n;
    cout << furui(n) <<endl;
}

  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
typedef long long LL;
using namespace std;
#define REPF( i , a , b ) for ( int i = a ; i <= b ; ++ i )
#define REP( i , n ) for ( int i = 0 ; i < n ; ++ i )
#define CLEAR( a , x ) memset ( a , x , sizeof a )
const int N=1e7;
int sum[N];
bool vis[N];
void initPrime()
{
    int num = 0, m = sqrt (N + 0.5);
    for (int i = 2; i <= m; ++i)
        if (vis[i] == 0)
            for (int j = i * i; j <= N; j += i) vis[j] = 1;
    sum[1]=0;
    for(int i=2;i<=N;i++)
    {
        if(!vis[i])  sum[i]=sum[i-1]+1;
        else   sum[i]=sum[i-1];
    }
//    for(int i=2;i<=10;i++)
//        cout<<"233  "<<sum[i]<<endl;
}
int main()
{
    int n;
    initPrime();
    while(~scanf("%d",&n))
        printf("%d\n",sum[n]);
    return 0;
}

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

const int MAX_N = 999999;
bool prime[MAX_N + 1];

void sieve()
{
  prime[0] = prime[1] = false;
  for(int i = 2; i <= MAX_N; ++i)
    prime[i] = true;
  for(int i = 2; i <= MAX_N; ++i)
    if(prime[i])
      for(int j = i * 2; j <= MAX_N; j += i)
	prime[j] = false;
}

int is_prime(int n)
{
  return prime[n];
}

int main()
{
  int n, i;
  int ans = 0;
  sieve();
  while(cin >> n){
    for(i = 0; i < n; i++){
      if(is_prime(i)){
	ans++;
      }
    }
    if(i == n){
      break;
    }
  }
  printf("%d\n", ans);
}

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

int main(){
	int n,w=1;
	while (cin >> n) {
		
		for(int j=n;j>1;j--){
			for(int i=2;i<j;++i){
				if(j%i == 0){
					break;
				}
				if(i==j-1){
	//				cout << j << endl;
					w++;
				}
			}
		}
		cout << w << endl;
		w = 1;
	}
	return 0;
}

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

int main() {
	int n, ans; bool check;
	while (cin >> n) {
		ans = 0;
		for (int i = 1; i <= n; i++) {
			if (i <= 3) {
				if (i != 1) { ans++; } continue;
			}
			else {
				if (i % 2 == 0 || i % 3 == 0) continue;
				if (i % 6 != 1 && i % 6 != 5) continue;
				check = true;
				for (int j = 5; j * j <= i; j += 6) {
					if (i % (j + 0) == 0) { check = false; }
					if (i % (j + 2) == 0) { check = false; }
					if (check == false) { break; }
				}
				if (check == true) ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}