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 := i - 1; j >= 1; j-- {
				if i%j == 0 && j != 1 {
					flag = true
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

C++: 
#include <iostream>
#include <cmath>
#include <vector>
#include <time.h>     // for clock()
using namespace std;

/*
1???2 ?????? n ?????§?????´??°???????????????
2??????????????£???????????°????????§???????°?????????????????????? p ??¨?????????????????????????????????????????°?????? p ??¨?????????
p ??\?????? p ????????°?????¨????¶????????????????
3???2??????????????°?????????????????????p ??? ???n ????¶??????????????????????????????????????????£?????????????´???°???
*/
// ??¨????????????????????????
int SieveOfEratosthenes(int num) {
	
	if (num < 2) {
		return 0;
	}
	// num???????´???°?????°
	int count = 0;
	int i = 2;
	while (i <= num) {
		if (i == 2) {
			count++;
			i++;
			continue;
		}
		else if (i % 2 == 0) {
			//count++;
			i++;
			continue;
		}
		else {
			// Route Num?????´??°??¨??????????????????
			int routeN_int = (int)sqrt(i);
			int j = 3;
			while (i % j != 0) {
				if (j > routeN_int) {
					count++;
					break;
				}
				j += 2;
			}
			i++;
		}
	}


	return count;
}

int main() {

	int num = 0;
	while (cin >> num, num != 0) {
		//clock_t start = clock();    // ??????????????????
		cout << SieveOfEratosthenes(num) << endl;
		//clock_t end = clock();     // ????????????
		//std::cout << "duration = " << (double)(end - start) / CLOCKS_PER_SEC << "sec.\n";
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
// have you mooed today?
bool isprime(int& num)
{
    static int c;
    static int max;
    max = sqrt(num) + 2;
    if(num == 2) return true;

    for(c=2; c < max; c++)
        if(num % c ==0) return false;
    return true;
}

int main()
{
    int ans;
    int buff;
    while(cin >> buff);
    {
        ans  = 0;
        for(int d =2; d <= buff; d++)
        {
            if(isprime(d)) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <stack>
#include <algorithm> 
#include <limits.h>  

using namespace std;

int gcd(int a,int b){
	if(b==0){
		return a;
	}
	else{
		return gcd(b,a %b);
	}
	
	
//	return b==0?a:gcd(b,a%b);
}
int exgcd(int a,int b,int &d,int &x,int &y){
    if(b==0)
    {
        d=a;
        x=1; 
		y=0;
    }
    else
    {
        exgcd(b,a %b,d,y,x);     // xa+yb=d
//		y=(d-x*a)/b;
		y-=x*(a/b);
    }
}
int eular(int n){    //oulahanshu
    int ret=1, i;  
    for(i=2; i*i<=n; i++) {  
        if(n %i == 0) {  
            n /= i;  
            ret *= i-1;  
            cout<<"ret  "<<ret<<endl;
            while(n %i == 0) {  
                n /= i;  
                ret *= i;  
                cout<<"ret2  "<<ret<<endl;
            }  
        }  
    }  
    if(n>1)  
        ret *= n-1;  
    return ret;  
}  

int is_Prime(int n){
	int flag=1;
	for(int i=2;i<sqrt(n)+1;i++){
		if(n %i==0){
			flag=0;
			break;
		}
	}
	return flag;
}


int isprime[1000001]={};

void Eratosthenes(){
	memset(isprime,1,sizeof(isprime)/sizeof(int));
	isprime[0]=0;
	isprime[1]=0;
	for(int i=2;i<=1000;i++){
		if(isprime[i]){
			for(int j=2*i;j<1000000;j+=i){
				isprime[j]=0;
			}
		}
	}
}

int tab[1000001]={};

void maketable(){
	tab[0]=0;
	for(int i=1;i<1000000;i++){
		if(isprime[i]){
			tab[i]=tab[i-1]+1;
		}
		else{
			tab[i]=tab[i-1];
		}
	}	
}

int main(){
	
	Eratosthenes();
	
	maketable();
	
	int n;
	while(scanf("%d",&n)!=EOF){
		cout<<tab[n]<<endl;
	}
	
	
	return 0;
}

C++: #pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	memset(vis, 0, sizeof(vis));
	memset(prime, 0, sizeof(prime));
	prime[0] = prime[1] = 0;
	for (int i = 2; i*i<= MAX; i++){
		if (!vis[i]){
			prime[i] = 1;
			for (int j = i + i; j <= MAX; j += i){
				vis[j] = 1;
				prime[j] = 0;
			}
		}
	}
	int sum = 0;
	for (int i = 0; i <= MAX; i++){
		if (prime[i]){
			sum++;
		}
		amount[i] = sum;
	}
	int n;
	while (cin >> n){
		cout << amount[n] << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
  int i, j, r, input;
  bool flag;
  while (cin >> input) {
    if (input < 2) return -1;
    for (i = 2, r = 0; i <= input; i++) {
      for (j = 2, flag = true; j < i; j++)
        if (i % j == 0) flag = false;
      if (flag) r++;
    }
    cout << r << endl;
  }
  return 0;
}

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

int main(){
    int n, ans = 0;
    bool judge = true;
    while(cin >> n){
        for(int i = 2; i <= n; i++){
            for(int j = 2; j < i; j++){
                if(i % j == 0){
                    judge = false;
                    break;
                }
            }
            if(judge)
                ans++;
            else
                judge = true;
        }
        cout << ans << endl;
        ans = 0;
    }
    return 0;
}

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


int main(){
	bool work[MAX + 1];
	int num, ans = 0;

	// 入力
	cin >> num;

	// 初期化
	for(int i = 0; i <= MAX; i++){
		if(i < 2){
			work[i] = false;
		}else{
			work[i] = true;
		}
	}

	// エラトネスのふるい
	for(int i = 2; i <= sqrt((double)MAX) + 1; i++){
		if(work[i] == true){
			for(int j = i * 2; j <= MAX; j += i){
				work[j] = false;
			}
		}
	}

	// 計算
	for(int i = 0; i <= num; i++){
		if(work[i] == true){
			ans++;
		}
	}

	// 出力
	cout << ans << endl;

	return 0;
}

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

using namespace std;


int main(){
	const int MAX_NUM=1000000;
	int table[MAX_NUM]={};
	for(int i=2;i<1001;i++){
		if(table[i]==1)continue;
		for(int j=i*2;j<MAX_NUM;j+=i){
			table[j]=1;
		}
	}

	int input;
	while(cin>>input){
		int count=0;
		for(int i=2;i<input;i++){
			//cout<<"table:"<<i<<"="<<table[i]<<"\n";		
			if(table[i]==0)count++;
		}
		cout<<count<<"\n";
	}
	return 0;
}

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

int main(){
int n;
cin >> n;
int a[n+1];
int b;
int c;
b=1;
while(b<n+1){
a[b]=0;
b=b+1;}
a[1]=1;
b=2;
while(b<n+1){
if(a[b]=0){ c=2; while(1){if(c*b>n){break;} a[c*b]=1; c=c+1;}
b=b+1;}

int d;
d=0;
b=1;
while(b<n+1){
if(a[b]=0){d=d+1;}
b=b+1;}
cout << d;


}

C++: #include <stdio.h>

#define MAX_V 1000001
int prime [MAX_V];

int main()
{
	int i, k, n, a=0, b=0;
	int cnt[MAX_V];

	for(i=2; i<MAX_V; i++)
	{
		prime[i] = 1;
	}

	for(i=2; i*i<=MAX_V; i++)
	{
		if(prime[i])
		{
			for(k=2*i; k<MAX_V; k+=i)
			{
				prime[k] = 0;
			}
		}
	}

	for(i=2; i<MAX_V; i++)
	{
		if(prime[i])
		{
			b++;
		}
		cnt[i] = b;
	}

	while(scanf("%d",&n)!= EOF)
	{
		printf("%d\n",cnt[n]);
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

#define NMAX 1000001
bool p[NMAX];
int c, cnt[NMAX];
void show(){
  for(int i = 0; i < 20; i++){
    cout << "@" << i << ":" << p[i] << endl;
  }
}
void prime(){
  fill(p, p+NMAX, true);
  p[0] = p[1] = false;
  for(int i = 4; i < NMAX; i+=2)p[i] = false;
  for(int i = 3; i*i < NMAX; i+=2){
    if(p[i]){
      for(int j = i+i; j < NMAX; j+=i){
	p[j] = false;
      }
    }
  }
  for(int i = 0; i < NMAX; i++){
    if(p[i])c++;
    cnt[i] = c;
  }
}
int main(){
  prime();
  int n;
  while(cin >> n){
    cout << cnt[n] << endl;
  }
  return 0;
}