Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := 2; j < MAX/i; j++ {
                                if i * j < MAX {
                                        primes[i*j] = 0
                                }
                        }
                }
        }
}

C++: #include<stdio.h>

int main(){
    int i,j,k,n,f;
    int stack[30],sp=0;
    while(scanf("%d",&stack[sp++])!=EOF);
    for(i=0;i<sp-1;i++){
        n=0;
        for(j=2;j<=stack[i];j++){
            f=0;
            for(k=2;k<j;k++)
                if(j%k==0)f=1;
            if(f==0)n++;
        }
        printf("%d\n",n);
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
#define ll long long
typedef pair<int, int> P;

bool prime[100005];


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

		int ans = 0;

		REP(i, 100005)prime[i] = true;
		prime[0] = prime[1] = false;
		FOR(i, 2, (int)sqrt(100005))
		{
			if (prime[i] == true)
			{
				FOR(j, 2, (int)sqrt(100005)){
					if (prime[i*j] == true)prime[i*j] = false;
				}
			}
		}
		REP(i, n + 1){
			if (prime[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
ll prime[1000001];
ll length = 0;
void insert(ll p) { prime[length] = p; length++; return; }
int main(){
	insert(2);
	for (ll i = 3; i < 1000000; i += 2) {
		for (ll j = 0; j < length; j++)
			if (i%prime[j] == 0)goto cont;
			else if (prime[j] > sqrt(i))break;
		insert(i);
	cont:;
	}
	ll n; while (cin >> n) {
		ll ans = 0;
		while (prime[ans] <= n){
			ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

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;
}