Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		input := nextInt()
		fmt.Println(IsPrime(input))
	}
}

func IsPrime(num int) int {
	eratos := make([]bool, num+1)
	c := 0
	for i := 2; i < len(eratos); i++ {
		if eratos[i] == false {
			c++
			eratosCalc(i, eratos)
		}
	}
	return c
}

func eratosCalc(primeNum int, eratos []bool) {
	for i := primeNum * primeNum; i < len(eratos); i += primeNum {
		eratos[i] = true
	}
}

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

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

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
    vector<int> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;

      v[0]=v[1]=false;
    for(int i = 2;i<1000;i++){
      if(v[i]){
        for(int j=i*i;j<MAX;j+=i){
         v[j]=false;
       }
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())break;;
      cout << v[a] << endl;
    }
    return 0;
}

C++: #include <stdio.h>

const int MAX_V = 1000000;
int prime[MAX_V+1];
int a[MAX_V] = {'0'};
int sum[MAX_V+1];
int main() {
  int i, k, v, j, m, n;
  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;
      }
    }
  }
  sum[0] = 0;
  for(m = 0; m < MAX_V; m++) {
    sum[m+1] = sum[m] + prime[m];
  }
  while( scanf( "%d", &n ) != EOF ) {
    for( j = 2; j <= n; j++ ) {
      int isprime = prime[j];
      int isprimee = prime[j-2];
    }
    printf( "%d", sum[n+1] );
  }
  return 0;
}

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


bool isPrime(int I)
{
	for(int i = 2; i < I; i ++){
		if(I % i == 0)
			return false;
	}
	return true;
}
void printPrime(int N)
{
	int total = 0;
	for(int i = 2; i <= N; i ++)
	{		
		if(isPrime(i) == true){
			total ++;
		}
	}
	cout<<total<<endl;
}


int main(){
	int n;
	while(cin>>n){
		printPrime(n);
	}
	
}

C++: #include <stdio.h>
#include <math.h>
int sosuu(int x){
    int n,m,sosuu;
    sosuu=x-1;
    for(n=2;n<x;n++){//nは素数を調べる。入力された数字まで１からスライドしていく。
        for(m=2;m<n;m++){//mはnが素数かどうか調べる。素数かどうかをnより小さい数字で数えていく。2からなのは2から素数だから。1はふくめない。
            if(n%m==0){//素数じゃなかったら、つまり割り切れてしまったら。
                sosuu--;
            }
            
            if(n%m==0) break;
        }
    }
    if(x==1||x==0) sosuu=0;
    return sosuu;
}

int main ( void ) {
    int s,result;
    while(scanf("%d",&s)!=EOF){
        result = sosuu(s);
        printf("%d\n",result);
    }
    return 0;
}

C++: #include <cstdio>
#include <cstring>
#define MAXN 1000010
bool is_prime[MAXN];
int prime[MAXN];

void find(int n) {
    memset(is_prime,1,sizeof(is_prime));
    is_prime[0]=is_prime[1]=false;
    prime[0]=0;
    for(int i=2;i<=n;i++) {
        if(is_prime[i]) {
            prime[++prime[0]]=i;
            for(int j=2*i;j<=n;j+=i) is_prime[j]=false;

        }
    }
}


int bifind(int n) {
    int b=1,e=prime[0],mid;
    while(b<=e) {
        mid=(b+e)>>1;
        if(n==prime[mid]) return mid;
        //printf("%d %d %d\n",b,mid,e);
        else if(n>prime[mid]) {b=mid+1;}
        else {e=mid-1;}
    }
    return b-1;
}
int main() {
    int n;
    find(999999);
    //printf("%d\n",prime[0]);
    //printa(prime,prime[0]);
    while(scanf("%d",&n)!=EOF) {
         int pos=bifind(n);
         printf("%d\n",pos);
    }
}

C++: /*#include <stdio.h>
  int main(){
    int a,b,c,d,n,sum=0;
      while(scanf("%d",&n) != EOF){
       for(a=0;a<10;a++){
          for(b=0;b<10;b++){
             for(c=0;c<10;c++){
                for(d=0;d<10;d++){
                    if(a+b+c+d==n)
                        sum++;
                          }
                            }
                             }
                               }
                                printf("%d\n",sum);
                                 sum=0;
                                   }
return 0;
}*/#include <stdio.h>
  int main(){
   int i,j,n,hantei=0;
   int sum=0;
    while(scanf("%d",&n) != 0){
    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<bits/stdc++.h>
using namespace std;

#define maxPN 500000
#define PNs  1000100
int countPN = 0, countPNs = 0;
int PrimeNum[maxPN], temp;
bool PN[PNs];

bool IsPrimeNumber(int x);

void PrimeN(){
	int i, j;
	PrimeNum[0] = 2;
	PN[2] = true;PrimeNum[countPN++] = 2;
	PN[3] = true;PrimeNum[countPN++] = 3;
//	PN[5] = true;PrimeNum[countPN++] = 5;
	
	for(i = 6; i  < PNs;i+=6){
		if(IsPrimeNumber(i-1)){
			PrimeNum[countPN++] = i-1;
			PN[i-1] = true;//cout<<i-1<<endl;
		}
		if(IsPrimeNumber(i+1)){
			PrimeNum[countPN++] = i+1;
			PN[i+1] = true;//cout<<i+1<<endl;
		}
		countPNs = i+1;//cout<<i-1<<" "<<PN[i-1]<<endl;
	}
}

bool IsPrimeNumber(int x){
	//if(x == 2 || x == 3) return true;
	//if(x <= 4 || x%2 == 0 || x%3 == 0)   return false;
	//if(x < countPNs) return PN[x];
	for(int i = 0; PrimeNum[i] * PrimeNum[i] <= x; i++)
		if(x%PrimeNum[i] == 0)return false;
	return true;
}


int main(){
//	clock_t start, end;
	int n = true, counta;
//	start = clock();
	PrimeN();
	cout<<PrimeNum[countPN-1]<<" "<<countPNs<<endl;
//	cout<<clock()-start<<"ms"<<endl;
	
	while(cin>>n){
		counta = 1;
		
		
		//cout<<(IsPrimeNumber(n)?"yes":"no")<<endl;
	//	start = clock();
		//cout<<IsPrimeNumber(n)<<endl;
		for(int i = 1; i <= n; i+=2){
			if(PN[i])counta++;
		//	cout<<i<<" "<<PN[i]<<endl;
		}
		if(n == 1) counta = 0;
		cout<<counta<<endl;
	//	cout<<clock()-start<<"ms"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
bool flag[10000001];
 
int main(){
    int n=0,ans=0;
    for(int i=0;i <= 1000000;i++){
        if(i<=1)flag[i]=false;
        else flag[i]=true;
    }
    for(int i=2;i <= 1001 ;i++){
        if(flag[i]==true){
            for(int j=i*2 ; j<=1000000 ; j=j+i){
                flag[j] = false;
            }
        }
    }
    while(cin>>n){
        ans=0;
        for(int i=0;i <= n;i++){
            if(flag[i]==true){
                ans++;
            }
        }
        cout<<ans<<endl;
    }
}

C++: #include<stdio.h>
#include<math.h>
int main(){
	int n,c,i,j,k;
	while(scanf("%d",&n)!=EOF){
		c=1;
		for(j=3;j<=n;j+=2){
			k=1;
			i=3;
			while( i <= sqrt(j) ){
				if(j%i==0){
					k=0;
					break;
				}
				i = i + 2;
			}
			if(k){
				c++;
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

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


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

	// 初期化
	for(int i = 6; i <= MAX; i++){
		for(int j = 2; j < (i / 2); j++){
			if (i % j == 0){
				work[i] = false;
				break;
			}else{
				work[i] = true;
			}
		}
	}
	work[0] = false;
	work[1] = false;
	work[2] = true;
	work[3] = true;
	work[4] = false;
	work[5] = true;

	// 出力
	while(cin >> num){		
		for(int i = 0; i <= num; i++){
			if(work[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
}

C++: ///bismillah_hir_rahmanir_rahim
///GALIB-2015331528

#include<bits/stdc++.h>
using namespace std;

int prime[1000000];
int main()
{
    int n,c;
    cin>>n;
    if(n==1){
        cout<<"0"<<endl;
        return 0;
    }

    c=1;
    for(int i=3;i<=n;i+=2){
        if(prime[i]==0){
            c++;
            for(int j=3;i*j<=n;j+=2)
                prime[i*j]=1;
        }
    }

    cout<<c<<endl;




    return 0;
}

C++: #include<stdio.h>

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

int main(void){
	int n,cnt=0;
	scanf("%d",&n);
	for(int i=2;i<n;i++){
		if(p(i)){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}