Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		flag := false
		count := 0

		for i := 2; i <= num; i++ { //1を除く入力値以下の数字
			for j := 2; j < i-1; j++ {
				if i%j == 0 && j != 1 {
					flag = true
					//fmt.Println(i, "/", j)
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n,k,s=1,sosuu[100010]={2};
  for(int i=3;i<=999999;i+=2){
    k=0;
    for(int j=3;j<=sqrt(i);j+=2){
      if(i%j==0){
	k=1;
	break;
      }
    }
    if(k==0){
      sosuu[s]=i;
      s++;
    }
  }
  while(cin>>n){
    int a=0;
    for(a=0;sosuu[a]<=n;a++){
      if(sosuu[a]==999983){
	a++;
	break;
      }
    }
    cout<<a<<endl;   
  }
  return 0;
}

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 <iostream>
#include <list>
#include <algorithm>

int main(){
	int NUM;
	while(std::cin >> NUM){
		std::list<int> numList,primeList;
		for(int i=2;i<=NUM;++i){
			numList.push_back(i);
		}
	
		for(int i=numList.front();i<std::sqrt(NUM);i=numList.front()){
			primeList.push_back(i);
			numList.erase(std::remove_if(numList.begin(),numList.end(),[&](int num){return num%i==0;}),numList.end());
		}
		int cnt=numList.size()+primeList.size();	
		std::printf("%d\n",cnt);
		}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>

using namespace std;


int main(){
	int n = 0;
	int count = 0;
	bool flag = false;
	while(cin >> n){
		for(int i = 0; i < n; i++){
			if(i == 2){
				count++;
			}
			else if(i % 2 != 0){
				for(int j = 3; j * j <= i; j += 2){
					if(i % j == 0){
						flag = true;
					}
				}
				if(flag != true){
					count++;
				}
			}
			flag = false;
		}

		cout << count << endl;

	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

#define MAX 1000000

using namespace std;

int main()
{
	char p[MAX]={1,1};
	int n,ans;

	for(int i=2;i*i<=MAX-1;i++){
		if(p[i]==0){
			for(int j=i*2;j<MAX;j+=i) p[j]=1;
		}
	}

	while(cin>>n){
		ans=0;
		for(int i=2;i<n;i++){
			 if(p[i]==0) ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: //C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;

typedef long long ll;
/*
bool is_prime(int n){
    for (int i = 2; i*i<=n;i++){
        if(n%i==0) return false;
    }
    return n!=1;
}
*/
vector<int> divisor(int n){
    vector<int> res;
    for( int i=1;i*i<n;i++){
        if(n%i==0){
            res.push_back(i);
            if(i!=n/i)res.push_back(n/i);
        }
        
    }
    return res;
}
map<int,int> prime_factor(int n){
    map<int,int> res;
    for(int i=2;i*i;i++){
        if(n%i==0){
            res[i]++;
            n=n/i;
        }
    }
    if(n!=1)res[n]=1;
}


const ll MAX_N=1000000;
//ll prime[MAX_N];
bool is_prime[MAX_N];

int sieve(int n){
    
    ll p=0;
    for(ll i=0;i<=n;i++) is_prime[i]=true;
    cout<<n<<endl;
    is_prime[0]=is_prime[1]=false;
    for(ll i=2;i<=n;i++){
        if(is_prime[i]){
            //prime[p++]=i;
            p++;
            for(ll j=i*2;j<=n;j+=i){
                is_prime[j]=false;
            }
        }
    }
    return p;
}

int main(){
    ll a;
    while(scanf("%lld", &a)!=EOF){
        cout<<sieve(a)<<endl;
    }
    return 0;}

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

using namespace std;

constexpr int ceil_sqrt(int x) {
  int ans = 0;
  while (ans*ans < x) { ++ans; }
  return ans;
}

template<int size>
struct Sieve {
  constexpr Sieve(): factor(), primes() {
    factor[0] = factor[1] = 1;
    for (int p = 2; p < size; ++p) {
      primes[p] = primes[p-1] + (factor[p]?0:1);
      if (factor[p]) { continue; }
      for (int n = 2*p; n < size; n += p) {
        factor[n] = p;
      }
    }
  }
  constexpr bool is_prime(int n) const {
    assert(n < size);
    return !(factor[n]);
  }
  int factor[size];
  int primes[size];
};

constexpr int NMAX = 1200000;
constexpr auto sieve = Sieve<NMAX>();

int main() {
  int N = 0;
  while (cin >> N) {
    cout << sieve.primes[N] << endl;
  }
  return 0;
}

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

/*void judge(int n){
	bool arr[1000003];
	for(int i = 2; i < 1000003; i++) arr[i] = true;
}
*/

int main(){
	bool arr[1000003];
	int n,count = 0;
	cin >> n;
	for(int i = 2; i < 1000003; i++) arr[i] = true;

	for(int i = 2; i < sqrt(n); i++){
		if(arr[i]) {
			for(int j = 0; i * (j + 2) <= n; j++) {
				arr[i * (j + 2)] = false;
			}
		}
	}
	for(int i = 2; i <= n; i++){
		if(arr[i]) count++;
	}

	cout << count << "\n";
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
    vector<int> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;

      v[0]=false;
      v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]==true){
        for(int j = i;j<MAX;j=j*j){
         v[i]=false;
       }
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())return 0;
      cout << v[a]<<endl;
    }
}

C++: #include <iostream>

using namespace std;

int main()
{
    long kazu;
    
    while (cin>>kazu)
    {
        int sosuu=0,kari;
        
        for (int i=1; i<=kazu; i++)
        {
            kari=0;
            
            for (int j=1; j<=i; j++)
            {
                
                if (i%j==0)
                    kari++;
                
            }
            
            if (kari==2)
                sosuu++;
            
        }
        
        
        cout<<sosuu<<endl;
    }
    
}

C++: #include <cstdio>
#define MAX 1000

int main(){
	int n;
	bool c[MAX]={true};
	int t[MAX];t[0] = 0;
	for(int i = 2;i < MAX;i++){
		for(int j = i;i*j < MAX;j++){
			c[i*j-1] = true;
		}
	}
	for(int i = 1;i < 15;i++){
		if(c[i])t[i]=t[i-1];
		else t[i] = t[i-1]+1;
	}
	while(scanf("%d", &n)){
		printf("%d\n", t[n-1]);
	}
	return 0;
}

C++: #include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> prime;
void init(){
	for(int i=2;i<999999;i++){
		bool isprime=true;
		for(vector<int>::iterator p(prime.begin());p!=prime.end();p++){
			if((*p)*(*p)>i)break;
			if(i%*p==0){
				isprime=false;
				break;
			}
		}
		if(isprime){
			prime.push_back(i);
		}
	}
}
int main(){
	int n;
	init();
	while(cin>>n){
		cout<<upper_bound(prime.begin(),prime.end(),n)-prime.begin()<<endl;
	}
	return 0;
}