Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [31]int
	var inputCount, primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		resultArr[inputCount] = primeCount
		if inputCount == 30 {
			break
		}
		primeCount = 0
		inputCount++
	}
	for _, v := range resultArr {
		fmt.Printf("%d\n", v)
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

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

#define MAX 1000000 

bool prime_table[MAX];
int head;

int main(){
	int n, i, j;
	int result;
	// make table
	for (i = 0; i < MAX; i++) {
		if(i==0||i==1){
			prime_table[i] = false;
		}else{
			prime_table[i] = true;
		}
	}
	// find prime
	for (i = 2; i < MAX; i++) {
		if(prime_table[i]){
			for (j = i+i; j < MAX; j+=i) {
				prime_table[j] = false;
			}
		}
	}
	
	while(cin >> n){
		result = 0;
		for (i = 0; i <= n; i++) {
			if(prime_table[i])
				result++;
		}
		cout << result << endl;
	}
	return 0;
}

C++: //36
#include<iostream>
 
using namespace std;
 
int main(){
  static bool cmp[1000000]={true};
  static int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
    cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1]+!cmp[i];
  }
  for(int n;cin>>n;n++){
    cout<<npr[n]<<endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define PII pair<int, int>
using namespace std;
const int MAXN = 1000000;

int sum[MAXN+5];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    sum[1] = 0;
    for (int i = 2; i <= MAXN; i++) {
        if (sum[i] == 0) {
            for (int j = i + i; j <= MAXN; j += i) {
                sum[j] = 1;
            }
        }
        sum[i] = sum[i - 1] + !sum[i];
    }

    int N;
    while (cin >> N) {
        cout << sum[N] << "\n";
    }
}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;

int main(void){
	int i,j,k,n,a=1;
	cin >> n;
	if(n==1){
		cout << "0\n";
		return 0;
	}
	for(i=3;i<=n;i+=2){
		k=0;
		for(j=3;j<=sqrt(i);j+=2){
			if(i%j==0){
				k=1;
				break;
			}
		}

		if(k==0) a++;
	}

	printf("%d\n",a);
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	bool a[1000000];
	for(int abc=2;abc<=999999;abc++){
		a[abc]=true;
	}
	for(int abc=2;abc<=999999;abc++){
		if(a[abc]==true){
			for(int ab=abc*2;ab<=999999;ab+=abc){
				a[ab]=false;
			}
		}
	}
	int ad;
	while(cin>>ad){
		int ansa=0;
		for(int abc=2;abc<=ad;abc++){
			if(a[abc]==true){
				ansa++;
			}
		}
		cout<<ansa<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;
int main()
{
    long long n;
    long long prime = 0;

    cin >> n;
    
    for(int x=1; x<=n; x++)
    {
            int counter = 0;
            for(int y=1; y<=x; y++)
            {
                    if(x%y==0)
                    counter++;
            }
            
            if(counter==2)
            {
                    cout << x << endl;
                    prime++;
            }
    }
    
    cout << prime << endl;
    
return 0;
}

C++: #include <cstdio>
 
int main(){
  bool cmp[1000000]={true};
  int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
    cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1]+!cmp[i];
  }
  for(int n;scanf("%d", &n);n++){
  	printf("%d\n", npr[n]);
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){

  int n;

  while(cin>>n){

	int cnt=0;
	
	if(n <= 1){
	  cout<<0<<endl;
	  continue;
	}

	else
	  cnt++;
	
	for(int i=3;i<=n;i+=2){
	  int f = true;
	  for(int j=2;j<i;j++){
		if(i%j==0){
		  f = false;
		  break;
		}
	  }
	  if(f == true)
		cnt++;
	}

	cout<<cnt<<endl;
	
  }

  return 0;
  
}

C++: #include <iostream>

bool Check(int);

int main(void)
{
    int input;
    int count;
    while(std::cin >> input){
        count = 0;
        for(int j=2;j <= input;++j){
            if(Check(j)){
                ++count;
            }
        }
        std::cout << count << std::endl;
    }
    return 0;
}
bool Check(int value)
{
    bool result = true;
    for(int i=value / 2;i >= 2;--i){
        if(value % i == 0){
            result = false;
            break;
        }
    }
    return result;
}

C++: //
//  main.cpp
//  CppTest
//
//  Created by Ryu on 2017/02/08.
//  Copyright ?? 2017??´ Ryu. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    long in[30];
    long out[30];
    int n = 0;
    long max = 0;
    while(cin >> in[n]){
        if(max < in[n]){
            max = in[n];
        }
        n++;
    }
    //printf("%d", n);
    
    long p[100000];
    //int length = sizeof(p) / sizeof(*p);
    int m = 0;
    //printf("length: %d", length);
    for (int i = 2; i <= max; i++) {
        bool prime = true;
        for(int j = 0; j < m; j++){
            if (i % p[j] == 0) {
                prime = false;
            }
        }
        if (prime) {
            p[m] = i;
            //printf("%ld\n", p[m]);
            m++;
        }
    }
    
    
    for (int i = 0; i < n; i++) {
        int s = 0;
        while (in[i] >= p[s] && p[s] != 0) {
            //printf("in: %ld, p: %ld\n", in[i], p[s]);
            s++;
        }
        out[i] = s;
        printf("%ld\n", out[i]);
    }
    
    return 0;
}