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<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  while(cin >> n){
    int cnt=0,res=0;
    for(int i=2; i<=n; i++){
      for(int j=1; j<=n; j++){
        if(i%j == 0) cnt++;
        if(cnt > 2) break;
      }
      if(cnt==2) res++;
      cnt = 0;
    }
    cout << res << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
inline bool prime(int x){
	for(int i=2;i<x;i++)
		if(!(x%i))	return false;
	return true;
}
int main(){
	int n;
	while(cin>>n){
		int ans=0;
		for(int i=2;i<=n;i++)
			if(prime(i))	ans++;
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n,S;
while(cin>>n)
{
	S=0;
	if(n==1)
	{
		cout<<0<<endl;
	}
	for(int i=2;i<=n;i++)
	{
		for(int j=i-1;j>1;j--)
		{
			if(i%j==0)
			{
				break;
			}
			if(j==2)
		{
			S++;
		}
		}	
			
	}
	cout<<S<<endl;
}
return 0;
}

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

int main(void){
  int n;
  while(cin >> n){
    int nums[n];
    int prime=0;
    for(int i=1;i<=n;i++){
      nums[i]=i;
    }
    for(int i=1;i<=n;i++){
      if(nums[i]>1){
	prime++;
	for(int j=2;nums[i]*j<=n;j++){
	  nums[nums[i]*j]=1;
	}
      }
    }
    cout << prime << endl;
  }
  
  return 0;
}

C++: //{Headers
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<queue>
#include<deque>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<bitset>

using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
#define mp(x,y) make_pair(x,y)
typedef long long ll;
//}

const int MAXN=1e6;
int N,nPrime[MAXN];

bool isPrime[MAXN];
void EratosthenesSeive(){
    memset(isPrime,true,sizeof isPrime);
    isPrime[0]=isPrime[1]=false;
    for(int i=2;i<MAXN;i++) if(isPrime[i]){
        for(int j=i<<1;j<MAXN;j+=i)
            isPrime[j]=false;
    }
}

void init(){
    EratosthenesSeive();
    nPrime[0]=0;
    for(int i=1;i<MAXN;i++) nPrime[i]=nPrime[i-1]+(isPrime[i]?1:0);
}

void solve(){printf("%d\n",nPrime[N]);}

int main(void){
//    freopen("in.txt","r",stdin);
    init();
    while(~scanf("%d",&N))
        solve();
    return 0;
}

/*
Sample Input
10
3
11
Output for the Sample Input
4
2
5
*/

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

int main(){
	int n=0,i,g,k,count=0,keta[6],result,wa3=0,wa4=0,wa8=0;
	double x,y;
	bool p=false;
	while(scanf("%d",&n)==1){
	for(x=0;x<6;x++){
		i=x;
		result=pow(10,x);
		keta[i]=n%result;
	}
	for(i=0;i<6;i++){
		wa3+=keta[i];
		if(i<1) wa4+=keta[i];
		if(i<2) wa8+=keta[i];
	}
	for(g=2;g<=n;g++){
		for(i=2;i<g;i++){
			if(i>n/2+1){
				if(wa3%3==0) break;
				if(wa4%4==0) break;
				if(wa8%8==0) break;
				if(n % i ==0){
				 p=true;
				 break;
				}
			}
			else if(g % i == 0){
				p=true;
				break;
			}
		}
		if(p) p=false;
		else{
			count++;
			p=false;
			}
		}
	printf("%d\n",count);
	count=0;
	wa3=0;
	wa4=0;
	wa8=0;
	}
	return 0;
}

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

int main()
{
	const size_t MAX = 1000000;

	bitset<MAX> primebox;
	primebox.set();
	primebox.reset(0);
	primebox.reset(1);

	for(int i = 2; i < MAX; i++)
	{
		if(!primebox.test(i))
			continue;

		for(int j = i*2; j < MAX; j += i)
			primebox.reset(j);
	}

	size_t n;
	while(cin >> n)
	{
		int found;
		if(n < 2)
			found = 0;
		else if(n == 2)
			found = 1;
		else
		{
			found = 1;
			for(size_t i = 3; i <= n; i += 2)
				if(primebox.test(i))
					found++;
		}

		cout << found << endl;
	}

	return 0;
}

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

using namespace std;
#define MAX_NUM 999999


void do_calc(int *numPrime){
  for(int i=2;i<=MAX_NUM;i++){
    bool 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;
    }
  }
}
  


int main(){
  int n;
  int numPrime[MAX_NUM];

  do_calc(numPrime);
  while(cin >> n){
    cout << numPrime[n] << endl;
  }
}

C++: #include<stdio.h>
bool b[4000000];

int main(void)
{
    int a,n,i;
    int count=0;
    int f=1;

    for(i=3;i<4000000;i+=2){
        f=1;
        for(a=2;a*a<=i;a++){
            if(i%a == 0){
                f=0;
                break;

            }
        }
        if(f==1){
            b[i]=1;
        }
    }
    b[2]=1;

    while(scanf("%d",&n)!=EOF){
        for(i = 0; i < n; i++){
            if(b[i]==1)count++;
        }

    printf("%d\n",count);
    count=0;
    }
    return 0;
}

C++: #include<cstdio>
#include<cmath>
#define SIZE 1000000
#define sizE 1000000

int prime[sizE], nprime=0;
int mark[SIZE];

void sieve()
{
    int i,j, limit=sqrt(SIZE*1.0)+2;

    mark[0]=1;
    mark[1]=1;

    for(i=4; i<=SIZE; i+=2)
        mark[i]=1;

    prime[nprime]=2;

    for(i=3; i<=SIZE; i+=2)
    {
           if(!mark[i])
            {
            prime[++nprime] = i;

            if(i<=limit)
            {
                for(j=i*i; j<=SIZE; j+=i*2)
                mark[j]=1;
            }
        }
    }

}

int main()
{
    int n;

    sieve();

    while(scanf("%d", &n)==1)
    {
        int i,k;
        i=k=0;

        while(i++<n)
        {
            if(!mark[i])
            k++;
        }

        printf("%d\n", k);
    }

    return 0;
}

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

int main()
{
	bool is_prime[1000000];
	memset(is_prime,false,sizeof(is_prime));
	for(int i=2;i<1000000;i++){
		if(!is_prime[i]){
//			cout<<i<<endl;
			for(int m=i*2;m<1000000;m+=i){
				is_prime[m]=true;
			}
		}
	}
	int n;
	while(cin>>n){
		int ans=0;
		for(int i=2;i<=n;i++){
			if(!is_prime[i]) ans++;
		}
		cout<<ans<<endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <limits.h>
using namespace std;
int main()
{
	int i = 0, maxV = INT_MIN, A[30] = {};
	for (int k; cin >> k; ) {
		A[i++] = k;
		if (maxV < k)
			maxV = k;
	}
	int s = maxV + 1;
	vector<long> vP(s, 0);
	int c = 0, j;
	for (int k = 2; k < s; ++k){
		if (vP[k] == 0){
			vP[k] = ++c;
			for (j = 2; j * k < s; ++j)
				vP[j * k] = -1;
		}
		else if (vP[k] == -1)
			vP[k] = c;		
	}
	for (j = 0; j < i; ++j)
		cout << vP[A[j]] << "\n";
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,n[100000],j,o=0;
	for(int i=2;i<=99999;i++){
		n[i]=1;
		
	}
	n[0]=n[1]=0;
		for( j=2;j<=99999;j++){
			if(n[j]){
				for(int k=j*2;k<=9999;k+=j){
				n[k]=0;
				}
			}
		}
		while(cin>>a){
	for(int k=2;k<=a;k++) if(n[k]) o++;
	cout<<o<<endl;
		}
}

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

int main(){
    int n, cnt;
    bool prime[1000000] = {false, false};

    for(int i = 2;i < 1000000;i++){
        prime[i] = true;
    }
    
    for(int i = 2;i <= sqrt(1000000);i++){
        if(prime[i]){
            for(int j = 2*i;j <= 1000000;j++){
                if(j%i == 0){
                    prime[j] = false;
                }
            }
        }
    }
    
    while(cin >> n){
        cnt = 0;

        for(int i = 2;i <= n;i++){
            if(prime[i]){
                cnt++;
            }
        }
        
        cout << cnt << endl;
    }

    return 0;
}