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++: #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 vis[N];  
void initPrime()  
{  
    int num = 0, m = sqrt (N + 0.5);  
    REPF(i,1,N)   vis[i]=1;  
    for (int i = 2; i <= m; ++i)  
        if (vis[i] == 1)  
            for (int j = i * i; j <= N; j += i) vis[j] = 0;  
    vis[1]=0;  
    for(int i=2;i<=N;i++)  
         vis[i]+=vis[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",vis[n]);  
    return 0;  
}

C++: #include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <cmath>

int main(void);
int count_prime_number(int n);

int main(){
	int n;
	int cnt = 0;
	int result[30];

	//while (cnt < 3){
		//std::cin >> n;
	while (std::cin >> n){
		result[cnt] = count_prime_number(n);
		cnt++;
	}

	for (int i = 0; i < cnt; i++){
		std::cout << result[i] << std::endl;
	}

	//while (1);
	return 0;
}


//0..nまでの素数の個数を出力する
//args:数値
//return:素数の個数
int count_prime_number(int n){
	int rtn = 0;

	//2だけ個別チェック
	if (n >= 2){
		rtn++;
	}

	for (int i = 3; i <= n; i+= 2)
	{
		bool is_prime_num = true;
		for (int j = 3; j <= sqrt(i); j+= 2)		//ルートi以上のiの約数はルートi以下のiの約数と対になっているので範囲はルートiまででいい
		{
			if (i % j == 0)
			{
				is_prime_num = false;
				break;
			}
		}

		if (is_prime_num){
			rtn++;

			//デバッグ
			//std::cout << i << std::endl;
		}
	}

	return rtn;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX_N = 1000000; 

vector<int> prime(MAX_N);
vector<bool> is_prime(MAX_N+1);

// n以下の素数を返す
int sieve(int n){
    int p = 0;
    rep(i, n+1) is_prime.at(i) = true;
    is_prime.at(0) = is_prime.at(1) = false;
    rep2(i, 2, n+1){
        if(is_prime.at(i)){
            prime.at(++p) = i;
            for (int j = 2*i; j <= n; j+= i) is_prime.at(j) = false;
        }
    }
    return p;
}

int main(){
    int n;
    while(cin >> n){
        cout << sieve(n) << endl;
    }
}

C++: /*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

int main() {
	int a;
	int count;
	int ccount;
	while (cin >> a)
	{
		count = 0;
		// ?´???°?????????
		// ??????????????°
		for (size_t i = 2; i < a; i++)
		{
			ccount = 0;
			// ????????°
			for (size_t j = 1; j <= i; j++)
			{
				//cout << "i= " << i << "j= " << j << endl;
				if (i % j == 0) {
					ccount++;
				}
			}
			if (ccount > 2) {
				count++;
			}
		}
		cout << count << endl;

	}
	return 0;
}

C++: #include<stdio.h>

int main(void){
  int n;
  while(scanf("%d",&n)!=EOF){
    if(n==1){
      printf("%d\n",0);
      break;
    }
    int p[100000];
    p[0]=2;
    int pi=1;
    int i=2;
    while(i<=n){
      int t=1;
      int j;
      for(j=0;j<pi;j++){
	if(i%p[j]==0){
	  t=0;
	  break;
	}
      }
      if(t==1){
	p[pi]=i;
	pi++;
      }
      i++;
    }
    printf("%d\n",pi);
  }
  return 0;
}

C++: #include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

//* calculate primes using sieve
ll sieve(ll n, vll &prime, vector<bool> &isprime){
    //* return the number of primes <= n
    //* prime[0]~ prime[p-1] record the primes
    //* isprime[0] ~ isprime[n] records the sieve
    ll p = 0;
    rep(i, n+1)
        isprime[i] = true;
    isprime[0] = isprime[1] = false;
    for(ll i=2; i <= n; i++){
        if(isprime[i]){
            prime[p++] = i; 
            for(ll j= 2*i; j <= n; j+= i)
                isprime[j] = false;
        }
    }
    return p;
}
int main(){
    vll prime(1000000);
    vector<bool> isprime(1000000);
    ll num = sieve(999999LL, prime, isprime);
    vll rec(1000000, 0);
    for(ll i=2; i< 1000000; i++){
        if(isprime[i])
            rec[i] = 1;
    }
    for(ll i=1; i< 1000000; i++){
        rec[i]+= rec[i-1];
    }

    ll n;
    while(cin >> n){
        cout << rec[n] << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
void multiple(int p,int* a,int n){
	for(int i=2*p;i<=n;i+=p){
		a[i]=1;
	}
}
int main() {
	int n;
	while(cin>>n){
		int a[n+1]={0};
		int count=0;
		for(int i=2;i<=n;i++){
        	if(a[i]==0){
        		count++;
        		multiple(i,a,n);	
        	}  		
		}
		cout<<count<<endl;
	}
	return 0;
}

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

int main(){

	int n, i, j, prmnum;
	bool prm = true;

	while(cin>>n){
		if(n==0)prmnum=0;
		else if(n==1)prmnum=0;

		else{

			prmnum = 1;

			for( i=3;i<=n;i+=2 ){
				prm = true;

				for( j=3;j<=sqrt((double)i);j+=2 ){
					if( i%j == 0 ){
						prm = false;
						break;
					}
				}


				if(prm)prmnum++;
			}
		}


		cout << prmnum << endl;
	}
	return 0;
}