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>
using namespace std;

int main(void)
{
  int prm[1000000];
  for (int i = 0; i < 1000000; i++) prm[i] = 1;
  prm[0] = prm[1] = 0;
  for (int i = 2; i < 1000000; i++) {
    for (int j = 2; i*j < 1000000; j++) {
      prm[i*j] = 0;
    }
  }
  int n;
  while (cin >> n) {
    int ans = 0;
    while (n) {
      if (prm[n]) ans++;
      n--;
    }
    cout << ans << endl;
  }

  return 0;
}

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

int main() {
	int n, count;
	bool *data;

	while (cin >> n) {
		data = new bool[n+1];
		count = 0;
		data[0] = data[1] = false;
		for (int i = 2;i <= n;i++) {
			if (data[i]) {
				count++;
				for (int j = i + i;j <= n;j += i) {
					data[j] = false;
				}
			}
		}
		cout << count << endl;
		delete[] data;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n;

    while(scanf("%d",&n)!=EOF){
        int sieve[n];
        for(int i=0;i<n;i++) sieve[i]=0;
        sieve[0]=sieve[1]=1;

        int lim=(int)sqrt(n);
    
        for(int i=2;i<=lim;i++){
            if(sieve[i]==0){
                int p=i;
                for(int j=(i+1);j<n;j++){
                    if(j%p==0) sieve[j]=1;
                }
            }
        }

        int cnt=0;
        for(int i=2;i<=n;i++){
            if(sieve[i]==0) cnt++;
        }

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

    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

using namespace std;

int main()
{
	vector<int> p;
	int flag,n;
	
	p.push_back(2);	p.push_back(3);	p.push_back(5);

	for(int i=7;i*i<999999;i++){
		flag=1;
		for(int j=0;j<p.size();j++){
			if(i%p[j]==0){flag=0;break;}
		}
		if(flag) p.push_back(i);
	}

	while(scanf("%d",&n)!=EOF){
		int ans=0;
		for(int i=0;p[i]<=n;i++) ans++;
		cout<<ans<<endl;
	}


	return 0;
}

C++: #include <stdio.h>

int main(void){
	bool a[1000000];
	int n = 0;
	int c = 0;
	while(scanf("%d", &n) != EOF){
		switch(n){
		case 1:
			c = 0;
			break;
		case 2:
			c = 1;
			break;
		default:
			c = 2;
			for(int i=3; i<=n/2; i+=2){
				a[i] = true;
			}
			for(int i=3; i<=n/2; i+=2){
				if(a[i] == false){ continue; }
				c++;
				for(int j=i; j<=n; j+=i){
					a[j] = false;
				}
			}
			break;
		}
		printf("%d\n", c);
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
        int n;
        int d; //素数を入れるための添字
        bool count; //割りきれるかどうかの判定
        int number[400000]; //素数を入れておく
        number[0] = 2;
        
        
        while(cin >>n){
                d = 0;
                for(int i = 3; i <= n; i++){
                        count = true;
                        for(int j = 0; j <= d; j++)
                                if(i % number[j] == 0)
                                        count = false;
                        if(count == true){
                                d++;
                                number[d] = i;
                        }
                }
        cout << d+1 << endl;
        }
}

C++: #include<iostream>
#include<math.h>
#include<string.h>
#define N 1000000
#define rep(i,a,b,c) for(int i=a;i<=b;i+=c)
using namespace std;
int a[1000000];
void seive (){
    int n=sqrt(N);
    int i,j;
    memset(a,0,sizeof(a));
    a[0]=a[1]=1;
    rep(i,2,n,1){
        if(!a[i]){
            rep(j,i+i,N,i){
                a[j]=1;
            }
        }
    }
}

int main(){
    seive();
    int m;
    while(cin>>m){
        int cnt = 0;
        rep(i,0,m,1){
            if(!a[i])cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)

using namespace std;

int main (void){
    
    int number[40] = {0};
    int answer[40] = {0};
    int i = 0,j = 0,k = 0;
    while(cin >> number[i])
    {
        for(k = number[i];k>1;k--)
            for (int l = 2; l<k; l++)
            {
                if( (k % l ) == 0)
                    break;
                if((k % l ) != 0 && (l == k -1) )
                    answer[i]++;
            }
        i++;
        
        
    
    }
    REP(j,i)
    cout << answer[j]+1 << endl;
    return 0;
    
}

C++: #include <stdio.h>

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