Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [100]int
	var inputCount, primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		resultArr[inputCount] = primeCount
		if inputCount == 30 {
			break
		}
		primeCount = 0
		inputCount++
	}
	for _, v := range resultArr {
		fmt.Printf("%d\n", v)
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

C++: #include<vector>
#include<algorithm>

std::vector<int> primeNumbers = {2, 3};
std::vector<bool> isPrime;

void eratosthenes(int n){
    int i, j;
    int s = 4;

    isPrime.assign(std::max(n + 1, 2), true);
    isPrime[0] = false;
    isPrime[1] = false;

    for(i = 4 ; i <= n ; i += 2){
        isPrime[i] = false;
    }
    for(i = 9 ; i <= n ; i += 6){
        isPrime[i] = false;
    }

    for(i = 5 ; i * i <= n ; i += s){
        if(isPrime[i]){
            primeNumbers.emplace_back(i);
            for(j = i * i ; j <= n ; j += i){
                isPrime[j] = false;
            }
        }
        s ^= 6;
    }
    for( ; i <= n ; i += s){
        if(isPrime[i]){
            primeNumbers.emplace_back(i);
        }
        s ^= 6;
    }

    return;
}

#include<iostream>

int main(){
    eratosthenes(999999);

    int n;
    while(std::cin >> n){
        std::cout << std::upper_bound(primeNumbers.begin(), primeNumbers.end(), n) - primeNumbers.begin() << std::endl;
    }

    return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM 1000000
using namespace std;

int num[MAXNUM]={0};

int main(){
  int n;
  while(cin >> n){
    vector<int> vec;
    vec.push_back(2);
    for(int i = 3; i<=n; i+=2){
      if(num[i]==1) continue;
      FOR(j, 2, MAXNUM){
        if(i*j>=n)  break;
        num[i*j]=1;
      }
      vec.push_back(i);
    }
    cout << vec.size() << endl;
  }
  return 0;
}

C++: #include<stdio.h>
const int MAX_N=99999;
bool is_prime[MAX_N+1];

int sieve(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]){
            p++;
            for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
        }
    }
    return p;
}

int main()
{
   int n;
   while(scanf("%d",&n)!=EOF)
   {
       printf("%d\n",sieve(n));
   }
   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 = 1;
			for(int i=3; i<=n; i+=2){
				a[i] = true;
			}
			for(int i=3; i<=n; 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<stdio.h>
#include<math.h>
#define DB(x) 
int prime[80000];
int GetPrime(int num);

int main(){
	int count = GetPrime(1000000);
	DB(printf("%d\n",count));
	int n,ans[100],cor = 0;
	int i;
	while(scanf("%d",&n) != EOF){
		for(i = 0;n >= prime[i] && i < count;i++);
		ans[cor] = i;
		cor++;
	}
	for(i = 0;i < cor;i++)
		printf("%d\n",ans[i]);
	return 0;
}

int GetPrime(int num){
	int i,j,count = 0;
	int sqnum = sqrt((double)num);
	for(i = 2;i <= num;i++){
		for(j = 0;j < count;j++){
			if(prime[j] > sqnum)
				goto COUNT;
			if(i%prime[j] == 0)
				break;
		}
		if(j < count)
			continue;
		COUNT:
		prime[count] = i;
		count++;
	}
	return count;
}

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

using namespace std;

int sum[1000001];
bool prime[1000001];

void sieve()
{
	fill_n(prime, 1000001, true);

	prime[1] = false;

	for (int i = 2; i <= 1000000; ++i) {
		sum[i] = sum[i - 1];
		if (!prime[i]) continue;
		sum[i]++;
		for (int k = i + i; k <= 1000000; k += i) {
			prime[k] = false;
		}
	}
}

int main()
{
	sieve();

	int n;
	
	while (~scanf("%d", &n)) printf("%d\n", sum[n]);
}

C++: #include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

bool p[1000000];

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

C++: #include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main() {
	const int MAX_V = 100000;
	int prime[MAX_V+1];
	int i, k, v;
	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;
			}
		}
	}
	for(i=0;i<30;i++){
		scanf("%d", &v);
		int count = 0;
		for(i=0;i<=v;i++){
			int isprime = prime[i];
			if(isprime) count ++;
		}
		printf("%d",count);
	}
	return 0;
}

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

	return 0;
}

C++: #include <stdio.h>

int main(void){
int n;
while(scanf("%d",&n)!=EOF){
int count=0;
for(int m=1;m<=n;m++){
bool check=true;
for(int i=2;i<m;i++){
if(i!=m && m%i==0){
check=false;
}
}
if(check==true){
count++;
}
}
}
return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long Int;

const int N = 1000000;
const int M = 1000;
const int K = 6000000;

vector<Int> iterativeSieve(){
    static int p[K], table[M];
    for(int i=2; i<M; i++) p[i] = i;
    for(int i=2; i*i<M; i++){
        if(p[i]){
            for(int j=i*i; j<M; j+=i){
                p[j] = 0;
            }
        }
    }
    p[0] = p[1] = 0;
    int num = remove(p, p+M, 0) - p;
    for(int m=M; m<N; m+=M){
        for(int x=m; x<m+M; x++){
            table[x-m] = x;
        }
        for(int i=0,j; p[i]*p[i]<m+M; i++){
            if(p[i] >= m)          j = p[i] * p[i];
            else if(m % p[i] == 0) j = m;
            else                   j = m - (m % p[i]) + p[i];
            for(; j<m+M; j+=p[i])  table[j-m] = 0;
        }
        num = remove_copy(table, table+M, p+num, 0) - p;
    }
    return vector<Int>(p, p+num);
}

int main(){
    vector<Int> prime = iterativeSieve();
    int n, cnt;

    while(cin >> n){
        cnt = 0;
        for(int i=0; prime[i] <= n && i < prime.size(); i++){
            cnt++;
        }
        cout << cnt << endl;
    }

    return 0;
}