Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [40]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++: __bowl1 = Array.new
__bowl2 = Array.new
__bowl3 = Array.new
__bowl4 = Array.new
__bowl5 = Array.new

india = gets.chomp.to_i
loop do
  srilanka = gets.chomp.to_i
  __bowl.push(srilanka)
  thai = gets.chomp.to_i
  puts __bowl.pop - thai

  india -= 1
  if india == 0
    break
  end
end

C++: #include<stdio.h>
#include<math.h>
int isprime(int x){
	int i;
	if(x == 2){
 		return 1;
	}
  	if(x<2||x%2==0){
		return 0;
	}
	i = 3;
	while( i <= sqrt(x) ){
		if(x%i==0){
			return 0;
		}
		i = i + 2;
	}
	return 1;
}
int main(){
	int l[999999]={0};
	int r=0,n;
	for(int i=0;i<999999;i++){
		if(isprime(i+1)){
			r++;
		}
		l[i]=r;
	}
	while(scanf("%d",&n)!=EOF){
		printf("%d\n",l[n-1]);
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


int main(){
    int n, ans, cnt, prime;

    while(cin >> n){
      prime = 1;
      for(int i=3; i <= n; i++){
        int j = 2;
        while(i%j !=0) j++;
        if(j == i) prime++;
      }
      cout << prime << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
#define MAX 999999
bool prime[MAX-1];
int main(void){ 
  
  prime[0] = prime[1] = false;
  //memeset(prime,sizeof(prime),true);
  fill(prime,prime+MAX,true);
  int ans[1000000];
  
  ans[0] = ans[1] = 0;
  ans[2] = 1;
  for(int i = 2 ; MAX > i * i ; i ++){
    ans[i] = ans[i-1] + prime[i];
    if(prime[i]){
      for(int j = i + i ; MAX > j * j ; j += i){
	prime[j] = false;
      }
    }
  }
  
  //  for(int i = 0 ; i < 10 ; i ++)cout<<ans[i]<<endl;
  int n;
  while(cin>>n){
    cout<<ans[n]<<endl;
  }
}

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

using namespace std; 

int list[1000000]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163,
 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251,
 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443,
 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557,
 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647,
 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757,
 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983,
 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069};

long int a,b,loop,hasil,input,mid;
long int lo;
long int hi;

 bool Prima(unsigned long n) 
{
    for (unsigned short i = 0; list[i]*list[i] <= n; i++) 
	{
        if (n % list[i] == 0) 
		{
            return false;
        }
    }
 
    return true;
}

int main()
{
	lo=1087;
	a=180;
	while(lo<=100003)
	{
		if(Prima(lo))
		{
			list[a]=lo;
			a++;
		}
		lo+=2;
	}
	//printf("%d",list[78498]);
	while(scanf("%ld",&input)!= EOF)
	{	
	lo=0;
	hi=78497;
	/*while(lo<=hi)
        {
            mid=(lo+hi)/2;
            if (list[mid]<input)
            {
                lo=mid+1; 
            } 
            else if(list[mid]>input)
            {
                hi=mid-1; 
            }
            else 
            {
                break; 
            } 
        }*/
	while(input>=list[lo])
	{
		lo++;
	}
	printf("%d\n",lo);
	}
	return 0; 
}

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

bool is_prime(int n){
for(int i=2;i*i<=n;i++){
if(n % i == 0) return false;
}
return n!=1;
}

int main(){
int n;

while(~scanf("%d",&n)){
int res=0;
for(int i=2;i<=n;i++){
if(is_prime(i)) res++;
}
printf("%d\n",res);
}
}

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

using namespace std;

int isprime(int x){
	int i;
	if(x == 2 || x == 3) return 1;
	else if(x % 2 == 0) return 0;
	else{
		for(i = 3; i <= sqrt(x); i += 2){
			if(x % i == 0) return 0;
		}
		return 1;
	}
}

int main(){
	int n, i, count;
	while(cin >> n){
		count = 0;
		for(i = 2; i <= n; i++){
			if(isprime(i) == 1) count++;
		}
		cout << count << endl;
	}
	return 0;
}

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

int main(void) {
  int n, *ar, *sum, i, j;
  if((ar = (int*)malloc(sizeof(int) * 1000000)) == NULL) return 1;
  if((sum = (int*)malloc(sizeof(int) * 1000000)) == NULL) return 1;
  for(i = 1; i < 1000000; ++i) ar[i] = 1, sum[i] = 0;
  for(i = 2; i < 1000; ++i) {
    if(ar[i]) for(j = 2; i * j < 1000000; ++j) ar[i * j] = 0;
  }
  for(i = 2; i < 1000000; ++i) sum[i] = sum[i - 1] + ar[i];
  while(scanf("%d", &n) != EOF) {
    printf("%d\n", sum[n]);
  }
  free(ar);
  free(sum);
  return 0;
}

C++: #include <iostream>
int a[1000000];
bool tf[1000000];
void f(){
    for(int i = 0;i < 1000000;i++){
        tf[i] = true;
    }
    tf[0] = tf[1] = false;
    for(int i = 2;i < 1000000;i++){
        if(tf[i]){
            for(int j = 2 * i;j < 1000000;j += i){
                tf[j] = false;
            }
        }
    }
    int sum = 0;
    for(int i = 1;i < 1000000;i++){
        sum = (tf[i] == true)? sum + 1 : sum;
        a[i] = sum;
    }
}
int main(){
    f();
    int x;
    while(std::cin >> x){
        std::cout << a[x] << "\n";
    }
    return 0;
}

C++: //AOJ 0009 Prime Number
//2016.6.25
//Algorithm:Prime
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;

const int maxn=1000006;
bool prime[maxn];
int n;
int cnt[maxn];

int main()
{
	for(int i=1;i<maxn;i++)
		prime[i]=true;
	prime[1]=false;
	for(int i=2;i<maxn;i++)
		if(prime[i])
			for(int j=i*2;j<maxn;j+=i)
				prime[j]=false;
	for(int i=1;i<maxn;i++)
		cnt[i]=cnt[i-1]+prime[i];
	while(cin>>n)
	{
		cout<<cnt[n]<<endl;
	}
	return 0;
}

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

const int C = (int)1e8;

bool isprime[C];
int prime[C];

void init() {
  fill(isprime, isprime+C, true);
  isprime[0] = isprime[1] = false;
  for (auto i=2; i<C; i++) {
    if (isprime[i]) {
      for (auto j=2; i*j<C; j++) {
	isprime[i*j] = false;
      }
    }
  }
  prime[0] = 0;
  for(auto i=1; i<C; i++) {
    prime[i] = ((isprime[i]) ? prime[i-1]+1 : prime[i-1]);
  }
}

int main() {
  init();
  int n;
  while (cin >> n) {
    cout << prime[n] << endl;
  } 
}