Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

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

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

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;
}

C++: import java.util.*;

class Prime2 {
    public static void main(String[] args) {
      
        Scanner scan = new Scanner(System.in);
        int[] x = new int[30];
        int t=0,j,count=0;
        
        
        while(scan.hasNextInt()){
        	count = 0;
			int lim = scan.nextInt();
        	int ptr = 0; //?????????????´???°?????°
        	int[] prime = new int[500000]; //?´???°???????´?????????????
        	
        	if(lim >= 2){
        		prime[ptr++] = 2; 
        		count++;
        	}
        	if(lim >= 3){
				prime[ptr++] = 3; 
				count++;
			}
			
        	for (int n = 5; n <= lim; n += 2) { 
        	    boolean wflag = false; 
        	    for (int i = 1; prime[i] * prime[i] <= n; i++) {
              
            	    if (0 == n % prime[i]) {
                    	wflag = true;
                    	break;
                	}
            	}
            	if (!wflag) { 
                	prime[ptr++] = n; 
                	count++; 
            	}
        	}
        	x[t] = count;
        	t++;
        	
		}
        	for (int i : x)  
            	System.out.println(i);
    }
}