Go: package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	//"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	for sc.Scan(){
		n := nextInt()
		fmt.Println(calc(n))
	}
}

func calc(n int)int{
	// エラトステネスで数え上げる
	// 最初から999999まで用意しておいて入力のたびO(1)で出すのとどっちが速いのかはわからん
	eratos := make([]bool, n+1)
	c := 0
	for i:=2; i<len(eratos); i++{
		if eratos[i] == false{
			c++
			for j:=i*i; j<len(eratos); j+=i{
				eratos[j]=true
			}
		}
	}
	return c
}

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

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

C++: #include <stdio.h>
#include <iostream>
#include <string.h>

using namespace std;



void markMultiples(bool arr[], int a, int n)
{
    int i = 2, num;
    while ( (num = i*a) <= n )
    {
        arr[ num-1 ] = 1; 
        ++i;
    }
}
 

void Sieve(int n)
{
	int count=0;
    
    if (n >= 2)
    {
        
        bool arr[n];
        memset(arr, 0, sizeof(arr));
 
        
        for (int i=1; i<n; ++i)
        {
            if ( arr[i] == 0 )
            {
                
                count++;
                markMultiples(arr, i+1, n);
            }
        }
    }
    cout<<count<<endl;
}
 

int main()
{
	for (int i=0; i<=30; i++)
	{
	
    int n ;
    cin >> n;
    
    
    Sieve(n);}
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <map>

using namespace std;

bool prime(int p){
	if ((p==0)||(p==1)){return false;}
	else if(p==2){return true;}
	else{
		for(int i=2; i*i<=p; i++){
			if(p%i == 0){return false;}
		}
	}
	return true;
}

int main()
{
	int n;
	map<int,bool> p;

	while(cin >> n){
		int count = 0;
		if(n>=2){count++;}
		for(int i=1; i<n+1; i=i+2){
			if(p[i]){count++;}
			else if(prime(i)){count++; p[i]=true;}
		}

		cout << count << endl;
	}
}

C++: #include<iostream>
using namespace std;
int d[1000000]={},p[1000000]={};
void calc(){
	for(int i=2;i<1000000;i++){
		if(d[i]==0){
			for(int j=2;j<1000000;j++){
				if(i*j>1000000) break;
					d[i*j]=1;
			}
		}
	}
	for(int i=2;i<1000000;i++){
		if(d[i]==0)
		p[i]=p[i-1]+1;
		else
		p[i]=p[i-1];
	}
}
int main(){
	calc();
	int n;
	while(cin>>n,n){
		if(cin.eof())break;
		cout<<p[n]<<endl;
	}
	return 0;
}

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

int main()
{
  int i, j;
  int n;
  int ans;
  int count;

  ans = 0;

  cin >> n;
  for (i = 2; i <= n; i++){
    count = 0;
    for (j = 1; j <= i; j++){
      if (i % j == 0){
        count++;
      }
    }

    if (count == 2){
      ans++;
    }
  }
  cout << ans << endl;

  return (0);
}

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

bool prime[MAX_N];

void ini()
{
	for (int i = 2; i < MAX_N; i++)
	{
		if (prime[i])
			continue;
		else
		{
			for (int j = i * 2; j < MAX_N; j += i)
			{
				if (!prime[j] && j%i == 0)
					prime[j] = true;
			}
		}
	}
}

void solve()
{
	int ans, num;
	while (cin >> num)
	{
		ans = 0;
		for (int i = 2; i <= num; i++)
			if (!prime[i])
				ans++;
		cout << ans << endl;
	}
}

int main()
{
	ini();
	solve();
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int a[1000001] = {0};
	for(int i = 0; i < 1000001; i++){
		a[i] = 1;
	}
	a[0] = 0;
	a[1] = 0;
	for(int i = 0; i < 100; i++){
		if(a[i]){
			for(int j = i * 2; j < 1000001; j += i){
				a[j] = 0;
			}
		}
	}

	int n;
	while(cin >> n){
		int k = 0;
		for(int i = 0; i <= n; i++){
			if(a[i]) k++;
		}
		cout << k << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>
#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;
	bool fl[1000001];
	memset(fl, true, sizeof(fl));
	for (int i = 2; i <= sqrt(num); i++) {
		if (fl[i]) {
			for (int j = 2; j*i <= num; j++) {
				fl[i*j] = false;
			}
		}
	}
	for (int i = 2; i <= num; i++) {
		if (fl[i]) {
			count++;
		}
	}
	return count;
}

int main() {

	int num = 0;
	while (cin >> num) {
		//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 <stdio.h>
  int main(){
   int i,j,n,hantei=0;
   int sum=0;
    while(scanf("%d",&n) != EOF){
    for(i=2;i<=n;i++){
      for(j=2;j*j<=i;j++){
        if(i%j != 0 || i == j){
            hantei += 0;
               }else{
                  hantei += 1;
                    }
}
if(hantei == 0){
sum++;
}
hantei=0;
}
printf("%d\n",sum);
sum=0;
hantei = 0;
}
return 0;
}

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


using namespace std;
#define MAX_NUM 999999


//int do_count(bool *isPrime, int n);

int main(){
  int n;
  bool flag = false;
  int numPrime[MAX_NUM];
  int pivot = 1;
  
  //  for(int i=0;i<MAX_NUM;i++){
  //numPrime[i] = 0;
  //  }
  
  while(cin >> n){
    int cnt=0;
    if(n < pivot){
      //      cout << "n < pivot" << endl;
      cnt = numPrime[n];
      cout << cnt << endl;
      continue;
      
    }
    
    //    if(n >= pivot){
    //  }
    
    for(int i=pivot+1;i<=n;i++){
      flag = false;
      //?´???°?????????????????§??????
      for(int j=2;j<=sqrt(i);j++){
	if(i%j==0){
	  flag = true;
	  break;
	}
      }
      if(flag){
	numPrime[i] = numPrime[i-1];
	continue;
      }else{
	numPrime[i] = numPrime[i-1] + 1;
      }
    }
    cnt = numPrime[n];
    cout << cnt << endl;
  }
}

C++: #include <stdio.h>

int main(){
	int sosuu[100000] = { 2, 3, 5 }, i, x, y = 3,n,z;
	
	while (scanf("%d", &n)!=0){
		z = 0; 
		for (i = 3; i < n + 1; i += 2){
			for (x = 0; x < y; x++){
				if (i % sosuu[x] == 0){ break; }
				if (x + 1 == y){ sosuu[y] = i, y++;}
			}
		}
		for (i = 0; i < y; i++){ if (sosuu[i] > n)break; z++; }
		printf("%d\n", z);
	}
	return 0;
}

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

int main(){
  int a;
  int i, j, k;
  int past=1, a_sqrt;
  int count;
  bool chk[1000000];

  for(i=1; i<1000000; i++) chk[i]=true;
  while(cin>>a){
    count=0;
    if(past>=a){
      for(i=1; i<=a; i++){
        if(chk[i]) count++;
      }
      printf("%d\n", count);
    }
    else {
      a_sqrt=(int)sqrt((double)a);
      for(i=2; i<=a_sqrt; i++){
        for(j=i; j<=a/i; j++){
          chk[j*i]=false;
        }
      }
      past=a;
      for(i=1; i<=a; i++){
        if(chk[i]) count++;
      }
      printf("%d\n", count);
    }
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
const int M = (1e6);
bool p[M];
short cnt[M];
void isPrime(){
  rep(i,M)p[i] = true;
  p[0] = p[1] = false;
  cnt[0] = cnt[1] = 0;
  loop(i,2,M){
    cnt[i] = cnt[i-1] + p[i];
    if(p[i])
      for(int j = i + i ; j < M ; j += i)
	p[j] = false;
  }
}
int main(void){
  isPrime();
  int n;
  while(cin>>n)cout<<cnt[n]<<endl;
}

C++: #include<cstdio>
#include<cmath>
#include<cstring>
int prime(long long num)
{
    for(int i=2;i<=sqrt(num);i++)
	if(num%i==0)
	    return 0;
    return 1;
}
int main()
{
    long long n;
    while (scanf("%lld",&n)!=EOF)
    {
    	int sum=0;
    	for (int i=2;i<=n;i++)
    	  if (prime(i)) sum++;
    	printf("%lld\n",sum);
	}
    return 0;
}