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++: // IncludingFiles
#include<iostream>
#include<vector>
#include<cmath>
#include<ctime>

// Defines
#define     MAX_NUMBER     (999999)
#define     MIN_NUMBER     (1)
// #define     __DEBUG__

// Using Namespace
using namespace std;

// Function
int main(){
	vector <int> PrimeNumbers;
	vector <int> input;
	int buf;
	int sz,maxn;
	int i,root;

	// 入力
	while(cin >> buf){
#ifdef __DEBUG__
		// 入力値のチェック
		if((buf < ((int)(MIN_NUMBER))) || (buf > ((int)(MAX_NUMBER)))){
			cerr << "InputError!!" << endl;
			return -1;
		}
#endif
		// 入力値をリストに追加
		input.push_back(buf);
	}

	// n の最大値を求めて maxn に代入
	sz = (int)input.size();
	maxn = input[0];
	for(i=1;i<sz;i++){
		if(maxn < input[i]){
			maxn = input[i];
		}
	}

	// 素数2 を 素数表PrimeNumbers に追加
	PrimeNumbers.push_back(2);

	// 3 から maxn までの整数が素数かどうかを調べ、素数であれば 素数表PrimeNumbers に追加
	for(i=3;i<=maxn;i+=2){
		// root に i の平方根を代入
		root = (int)sqrt(i);
		// sz に 素数表PrimeNumbers の大きさを代入
		sz = (int)PrimeNumbers.size();
		// i が 素数表PrimeNumbers に含まれている素数で割り切れないかを確認
		for(buf=0;(buf < sz) && (PrimeNumbers[buf] <= root);buf++){
			if((i % PrimeNumbers[buf]) == 0){						// もし割り切れたら
				goto NotPrime;										// i を素数表に追加しない
			}
		}
		// i は素数である ならば i を 素数表PrimeNumbers に追加
		PrimeNumbers.push_back(i);
		// ここにジャンプする
		NotPrime:;
	}

	// n 以下の素数の個数を計測
	sz = (int)input.size();
	for(i=0;i<sz;i++){
		// a, b および flag の宣言・初期化
		int a = 0,b = (int)PrimeNumbers.size() - 1,m,n;
		bool flag = false;

		// PrimeNumbers の最大値 <= input[i] となっていないかどうかを調べる
		if(PrimeNumbers[b] <= input[i]){
			n = b;
			flag = true;
		}

		// 二分検索
		while (flag == false){
			m = (a + b) / 2;
			if(PrimeNumbers[m] > input[i]){
				b = m;
			}else if((PrimeNumbers[m] <= input[i]) && (PrimeNumbers[m+1] > input[i])){
				n = m;
				flag = true;
			}else if(PrimeNumbers[m] < input[i]){
				a = m;
#ifdef __DEBUG__
			}else{
				cerr << "BinarySearchError!!" << endl << endl;
				cerr << "PrimeNumbers[" << m << "] = " << PrimeNumbers[m] << endl;
				cerr << "PrimeNumbers[" << (m + 1) << "] = " << PrimeNumbers[m+1] << endl;
				cerr << "input[" << i << "] = " << input[i] << endl;
				return -1;
			}
#else
			}
#endif
		}

		// 出力
		cout << n + 1 << endl;
	}

	return 0;
}

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

using namespace std;

bool isPrime(int x);

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

bool isPrime(int x) {
	if(x < 2)			return false;
	else if(x == 2)		return true;
	
	if(x % 2 == 0)		return false;
	for(int i = 3; i * i <= x; i += 2) {
		if(x % i == 0)	return false;
	}
	return true;
}

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

int main(){
  int n[1000000]={0};
  int i,j;

  for(i=2;i<=999999;i++){
    for(j=2;j<=(int)sqrt((double)i);j++){
      if(i%j == 0)
	break;
      if(j==(int)sqrt((double)i) && i%j!=0)
	n[i]=1;
    }
  }

  n[2]=1;
  n[3]=1;

  int k,l;
  while(scanf("%d", &k) != EOF){
    int m=0;
    for(l=2;l<=k;l++){
      if(n[l]==1)
	m++;
    }
    printf("%d\n",m);
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>

using namespace std;

int main() {

	int n, count = 0;
	int a[9999] = { 0 };
	
	// ??¨???????????????????????????

	while (cin >> n){

		for (int i = 2; i <= n; i++) {
			a[i] = 1;
		}

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

		for (int i = 2; i <= n; i++) {
			if (a[i] == 1)
				count++;
		}

		cout << count << endl;
		count = 0;
	}

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int n;
int main(){
	while(cin>>n){
		int sum=0;
		if(n<=100000){
			for(int i=2;i<=n;i++){
				for(int j=2;j<=sqrt(i);j++){
					if(i%j==0){
						goto loopa;
					}
				}
				sum++;
				loopa:;
			}
			cout<<sum<<endl;
		}
		else{
			for(int i=100001;i<=n;i++){
				for(int j=2;j<=sqrt(i);j++){
					if(i%j==0){
						goto loopb;
					}
				}
				sum++;
				loopb:;
			}
			cout<<sum+9592<<endl;
		}
	}
	return 0;
}

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

const int MAX_N = 999999;
int prime[MAX_N];
bool is_prime[MAX_N + 1];

int sieve(int n)
{
	int p = 0;
	for (int i = 0; i <= n; i++)
		is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;

	for (int i = 2; i <= n; i++)
	{
		if (is_prime[i])
		{
			prime[p++] = i;
			for (int j = i * 2; j <= n; j += i)
				is_prime[j] = false;
		}
	}
		return p;
}

int main()
{
	int n;
	while (scanf("%d", &n) != EOF)
	{
		int ans = sieve(n);
		printf("%d\n", ans);
	}
	return 0;
}

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

int p[MAX];

int main(){
	int counter = 0;
	p[1] = 0;
	for (int i = 2; i < MAX; i++){
		int sqrti = (int)sqrt(i);
		counter++;
		p[i] = counter;
		for (int j = 2; j <= sqrti; j++){
			if (i % j == 0){
				counter--;
				p[i] = counter;
				break;
			}
		}
	}
	int n;
	while (cin >> n){
		cout << p[n] << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(){ 
    int n;
    scanf("%d",&n);
    int prime[999999]={};
    for(int i=2;i<=n;i++){ 
        for(int j=2;i*j<=n;j++){ 
            prime[i*j]=1;
        }
    }
    int ans=0;
    for(int i=2;i<=n;i++){
        if(prime[i]==0)ans++;
    }
    printf("%d\n",ans);
}

C++: #include <iostream>
using namespace std;
#define x 1000000
int main(){
	bool q[x];
	for(int i=2;i<x;i++) q[i] = true;
	for(int i=2;i<x;i++) if(q[i]) for(int j=2;j<=x/i;j++) q[i*j] = false;
	int n;
	while(cin >> n){
		int a = 0;
		for(int i=2;i<=n;i++) if(q[i]) a++;
		cout << a << endl;
	}
}

C++: #include <iostream>
using namespace std;
#define max 1000000
 
int main()
{
    int prime[max];
    
    fill(prime, prime + max, 1);
    prime[0] = 0;
    prime[1] = 0;
    for (int i = 2; i < max; i++) {
        if (prime[i]) {
            for (int j = 2*i; j < max; j += i) {
                prime[j] = 0;
            }
        }
    }
    
    for(int i = 1;i < max; i++){
	    prime[i] = prime[i] + prime[i-1];
    }
    
    int aaa;
    while (cin >> aaa) {
	cout << prime[aaa] << endl;
    }
    return 0;
}

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

bool *f;

int main(){
	int n;
	while(cin>>n){
		f=new bool[n+1];
		for(int i=0;i<n;i++) f[i]=false;
		f[0]=true;
		f[1]=true;
		int l=sqrt(n);
		for(int i=2;i<=l;i++){
			for(int j=2;j*i<=n;j++){
				f[j*i]=true;
			}
		}
		int cnt=0;
		for(int i=0;i<=n;i++) if(!f[i])cnt++;
		cout<<cnt<<endl;
		delete []f;
	}
}