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++: //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

bool isPrime(int n){
	int upper = sqrt(n);
	if(n == 2) return true;
	if(n % 2 == 0 ) return false;
	for(int i=3; i<=upper; i=i+2){
		if(n % i == 0) return false;
	}
	return true;
}

int num_prime(int n){
	int counter = 0;
	for(int i=2; i<=n; i++){
		if(isPrime(i)) counter++;
	}
	return counter;
}


int main(){
	int n;
	while(cin >> n){
		cout << num_prime(n) << endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
        long long  n=1, j=0, arr[30];
//      while( n>0){
        long long count=1;
        cin >> n;
        if(n==1){
        count = 0;
        goto END;}
        if(n==2)
                goto END;
        for(int i=3; i<=n; i+=2){
                if(i == 3 || i == 5 || i == 7)
                        count++;
                if (i % 3 ==0 || i % 5 == 0 || i % 7 == 0)
                        continue;
                else
                        count++;
        }
        //      END:arr[j++] = count;
//}
        //for(int i=0; i<j; i++){
                END:cout << count << endl;
//}


        return 0;

}

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

int main(){
	int n[1000000]={0};
	int tmp=0,a;
	
	n[0]=1;
	n[1]=1;
	for(int i=2;i<1000000;i++){
		for(int j=2;i*j<1000000&&n[i]!=1;j++){
			n[i*j]=1;
		}
	}
	
	while(cin>>a){
		tmp=0;
		for(int i=0;i<=a;i++){
			if(n[i]==0) tmp++;
		}
		cout<< tmp << endl;
	}
	return 0;
}

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

using namespace std;

bool is_prime(const unsigned n);


int main(){
	int n;

	while(cin >> n){
		int ans=0;

		for(int number=2;number<=n;number++){
			if(is_prime(number))ans++;
		}
		printf("%d\n",ans);
	}


	return 0;
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: 
        case 1: return false;
        case 2: 
        case 3: return true;
    } 

    if(n%2 == 0) return false;
    if(n%3 == 0) return false;

    if(n%6 != 1 && n%6 != 5) return false;

    for(unsigned i=5;i*i<=n;i+=6){
        if(n%i     == 0) return false;
        if(n%(i+2) == 0) return false;
    }

    return true;}

C++: #include <cstdio>  
#include <iostream>  
using namespace std;  
int prime[1000005];  
bool is_prime[1000005];  
int seve(int n)  
{  
    int p=0;  
    for(int i=0;i<=n;i++)  
        is_prime[i]=true;  
    is_prime[0]=is_prime[1]=false;  
    for(int i=2;i<=n;i++)  
    {  
        if(is_prime[i])  
        {  
            prime[p++]=i;  
            for(int j=2*i;j<=n;j+=i)  
                is_prime[j]=false;  
        }  
    }  
    return p;  
}  
int main(void)  
{  
    int n;  
    while(scanf("%d",&n)!=EOF)  
    {  
        printf("%d\n",seve(n));  
    }  
    return 0;  
}

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

using namespace std;

int main(){
  
  int n;
  
  while(cin >> n){
    bool d[1000000];
    int ans = 0;
    
    for(int i = 1;i <= n;i++){
      d[i] = true;
    }
    d[1]  = false;
    
    for(int i = 1;i <= n;i++){
      if(d[i] == true){
	ans++;
	for(int j = 1;j*i <= n;j++){
	  d[i*j] = false;
	}
      }
    }
    
    printf("%d\n",ans);
  }
  
  return 0;
  
}

C++: #include <iostream>
using namespace std;
bool prime[1000000];
void sieve() {
    fill_n(prime, 1000000, true);
    for (int i=2; i<=1000; ++i) {
        if (prime[i]) {
            for (int j=i; i*j<1000000; ++j) {
                prime[i*j] = false;
            }
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    sieve();
    int n;
    while (cin >> n) {
        int cnt = 0;
        for (int i=2; i<=n; ++i) {
            if (prime[i]) {
                cnt ++;
            }
        }
        cout << cnt << "\n";
    }
    return 0;
}

C++: j,a['   '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}

C++: #include<iostream>
using namespace std;
main(){
int n;
    while(cin>>n){
        cout<<n<<endl; 
   }
}

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

int main(){
  int a[1000000];
  int N=1000000;
  for(int i=0 ; i<N;i++)
    a[i]=1;

  for(int i=2; i<sqrt(N);i++){
    if(a[i]){
      for(int j=0 ; i*(j+2)<N;j++){
          a[i*(j+2)]=0;
      }
    }
  }
  int n;
  while(cin >>n){
  int sum=0;
  for(int i=2;i<=n;i++)
        sum+=a[i];
        cout << sum<<endl;
  }
}

C++: #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e6+5;
int prime[maxn];
bool p[maxn];
int cnt=0;
void is_prime()
{
    memset(p,true,sizeof(p));
    p[0]=p[1]=false;
    for(int i=2;i<=maxn;i++)
        if(p[i]) {
            prime[cnt++]=i;
            for(int j=i*i;j<=maxn;j+=i)
                 p[j]=false;
        }
}
int main()
{
    is_prime();
    int n;
    while(scanf("%d",&n)==1)
    {
        int k=lower_bound(prime,prime+cnt,n)-prime;
        if(prime[k]==n) k++;
        printf("%d\n",k);
    }
    return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;
#define MAX_N 999999
int main()
{
    int n;
    bool notPrime[MAX_N+1];
    int count[MAX_N+1];
    for (int i = 2 ; i <= MAX_N ; i++)
    {
        if (!notPrime[i])
        {
            for (int g = i+i ; g <= MAX_N ; g += i)
            {
                notPrime[g] = true;
            }
        }
    }
    int cnt = 0;
    count[1] = 0;
    for (int g = 2 ; g <= MAX_N ; g++)
    {
        if (!notPrime[g])
            cnt ++;
        count[g] = cnt;
    }
    while (cin >> n)
    {
        cout << count[n] << endl;
    }
    
}

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

using namespace std;

bool judge_Prime_num(const int& num) {
	if (num < 2)
		return false;
	else if (num == 2)
		return true;
	else if (num % 2 == 0)
		return false;

	double sqrtnum = sqrt(num);
	for (int i = 3; i <= sqrtnum; i += 2) {
		if (num%i == 0)
			return false;
	}
	return true;
}

int main() {
	int n;
	while (cin >> n) {
		//clock_t start = clock();
		int tmp = n;
		int cnt = 0;
		while (tmp > 1) {
			if (tmp != 2 && tmp % 2 == 0) {
				--tmp;
				continue;
			}
			if (judge_Prime_num(tmp)) {
				++cnt;
			}
			--tmp;
		}
		cout << cnt << endl;
		//clock_t end = clock();
		//cout << cnt << "     " << (double)(end - start) / CLOCKS_PER_SEC << "sec" << endl;
	}
}