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<stdio.h>
#include<memory.h>
#include<math.h>
int a[999999]={0};
int main()
{
	int n,max=0;
	while(~scanf("%d",&n))
	{
		if(max>n) 
		{
			printf("%d\n",a[n]); 
			continue;
		}
		
		int sum=0;
		for(int i=max;i<=n;i++)
		{
			int flag=0;
			for(int j=2;j<=sqrt(i*1.0);j++)
				if(i%j==0) 
				{
					flag=1;
					break;
				}
			if((flag==0)&&i!=0&&i!=1) sum++;
			a[i]=a[max]+sum;
		}
		max=n;
		printf("%d\n",a[n]);
	}
	return 0;
}

C++: #include <cstdio>
#define N 999999
unsigned char p[((N+1)/2+7)/8];
int main() {
	int i,j,s,n=3;
	for(i=0;n<=(N/2);i++,n+=2)
		if(!(p[i/8]&(1<<(i%8))))
			for(j=i+n;j<((N+1)/2);j+=n)p[j/8]|=(1<<(j%8));
	while(scanf("%d",&n)!=EOF) {
		if(n<2){printf("0\n");continue;}
		if(n==2){printf("1\n");continue;}
		for(i=3,j=0,s=1;i<=n;i+=2,j++)
			s+=!(p[j/8]&(1<<(j%8)));
		printf("%d\n",s);
	}
}

C++: #include <iostream>
#include <cmath>
#define rep(i,N) for(int i = 0; i<(int)(N); i++)
#define REP(i,k,N) for(int i = k; i<(int)(N); i++)
using namespace std;
const int MAX_N = 10000010;
bool d[MAX_N];
int main(){
        int n;
        cin >> n;
        rep(i,MAX_N) d[i]=true;
        for(int i = 2; i< sqrt(n+1); i++) {
                if(d[i]) {
                        for(int j = 2; i*j<n+1; j++) {
                                d[i*j]=false;
                        }
                }
        }
        int ans = 0;
        REP(i,2,n+1){
                if(d[i]) ans++;
        }
        cout << ans << endl;


        return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<int> prime_list;
  bool flag;

  prime_list.push_back(2);
  for (int i = 3; i < 999999; i++) {
    for (int j = 0; j < prime_list.size(); j++) {
      if(i%prime_list[j] == 0) {
        flag = false;
        break;
      } else {
        flag = true;
      }
    }
    if (flag) {
      prime_list.push_back(i);
    }
  }

  int data, count;
  while(cin >> data) {
    for (int i = 0; i < prime_list.size() && prime_list[i] <= data; i++, count = i);
    cout << count << endl;
  }
}

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

int main(){
	int n;
	
	while(cin >> n){
		int a=0;
		for(int i = 1; i <= n; ++i){
			for(int j = 2; j <= i; ++j){

				if(i%j == 0){
				if(i==j){
					++a;
				}else{
					break;
				}
				}
		}
	
	}
		cout << a << '\n';
	}
}

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

int isPrime(int n);

int dp[1000000]={};

int main(){
  int n;
  for(int i=2;i<=1000000;i++){
      if(isPrime(i)) dp[i]=dp[i-1]+1;
      else dp[i]=dp[i-1];
  }
  
  while(cin >> n){
    cout << dp[n]<< endl;
  }
  
}

int isPrime(int n){
  for(int i=2;i*i<=n;i++){
    if(n%i==0) return 0;
  }
  return 1;
}

C++: #include<bits/stdc++.h>
#define N 1000000
using namespace std;

bool prime[N+5];
int C[N+5];

void seive(){
    memset(prime,true,sizeof(prime));
    prime[1]=false;
    for(int i=4;i<=N;i+=2) prime[i]=false;
    for(int i=3;i<=sqrt(N);i+=2){
        if(prime[i])
            for(int j=i*i;j<=N;j+=2*i)
                prime[j]=false;
    }
    //for(int i=1;i<N;i++) if(prime[i]) cout<<i<<endl;
    int c=0;
    for(int i=1;i<=N;i++){
        if(prime[i]) c++;
        C[i]=c;
        //cout<<C[i]<<endl;
    }
}

int main(){

    seive();
    int x;
    while(scanf("%d",&x)==1)
        printf("%d\n",C[x]);
}

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

int main(){
    int n, ans = 0;
    bool judge = true;
    while(cin >> n){
        for(int i = 2; i <= n; i++){
            for(int j = 2; j < i; j++){
                if(i % j == 0){
                    judge = false;
                    break;
                }
            }
            if(judge)
                ans++;
            else
                judge = true;
        }
        cout << ans << endl;
        ans = 0;
    }
    return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int const M=31;
int a,hantei[M];

int main(){
  hantei[0]=hantei[1]=1;
  for(int i=2;i<M;i++){
    if(hantei[i]==0){
      for(int j=2;j*i<M;j++){
	hantei[j*i]=1;
      }
    }
  }
  for(;cin>>a;){
    int count=0;
    for(int i=0;i<=a;i++){
      if(hantei[i]==0)count++;
    }
    cout<<count<<endl;
  }
}

C++: #include <cstdio>
#include <vector>
#include <ctime>

using namespace std;

int main()
{
	int n;
	vector<int> prime;
	
	//unsigned long t = time(NULL);
	for (int i = 3; i < 1000000; i += 2){
		int j;
		for (j = 0; j < prime.size(); j++){
			if (i % prime[j] == 0){
				break;
			}
		}
		if (j >= prime.size()){
			prime.push_back(i);
		}
	}
	//printf("%lu\n", time(NULL) - t);
	while (scanf("%d", &n) != EOF){
		int count;
		
		for (count = 0; prime[count] <= n; count++){//;
			//printf("%d\n", prime[count]);
			;
		}
		if (n >= 2){
			count++;
		}
		printf("%d\n", count);
	}
	
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <vector>
using namespace std;
// have you mooed today?
bool isprime(int& num)
{
    static int c;
    static int max;
    if(num == 1) return false;
    if(num == 2) return true;
    if(num % 2 == 0) return false;
    max = ceil(sqrt(num));

    for(c=3; c < max+1; c+=2)
        if(num % c ==0) return false;
    return true;
}

int main()
{
    int ans =0;
    int c;
    int buff;
    vector<int> prime;
    for(c=1;c<=999999;c++)
    {
        if(isprime(c)) ans++;
        prime.push_back(ans);
    }
    while(cin >> buff)
    {
        cout << prime[buff -1] << endl;
    }
    return 0;
}

C++: #include <cstdio>
#define MAX 1000000
#define SQRT 1000
#define TRUE 1
#define FALSE 0
using namespace std;

int is_prime[MAX];
int prime_count[MAX];

void solve() {
  int cnt = 0;
  for (int i = 0; i < MAX; i++) {
    is_prime[i] = TRUE;
  }
  is_prime[0] = is_prime[1] = 0;
  for (int i = 2; i < MAX; ++i) {
    if (is_prime[i] == TRUE) {
      if (i < SQRT) {
        for (int j = i * i; j < MAX; j += i) {
          is_prime[j] = FALSE;
        }
      }
      cnt++;
    }
    prime_count[i] = cnt;
  }
}

int main() {
  solve();
  int n;
  while (~scanf("%d", &n)) {
    printf("%d\n", prime_count[n]);
  }
}

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

using namespace std;

#define MAX_VALUE 1000000

int get_numprime( int num );

int main(void)
{
	int num;

	while(1)
	{
		cin >> num;
		if( cin.eof() ) break;
		int result = get_numprime( num );
		cout << result << endl;
	}

	return 0;
}

int get_numprime( int num )
{
	int numprime = 1; // 2はカウント済み

	bool erat[MAX_VALUE] = {0};

	for( int i = 0 ; i < num+1 ; i++ )
	{
		erat[i] = true;
	}
	erat[0] = false; erat[1] = false;
	for( int i = 2 ; i <= num ; i++ )
	{
		if( erat[i] )
		{
			for( int j = i*2 ; j <= num ; j+=i )
			{
				erat[j] = false;
			}
		}
	}
	for( int i = 3 ; i <= num ; i+=2 )
	{
		if( erat[i] ) numprime++;
	}

	return numprime;
}

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

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

int main() {
	vector<int> v = vector<int>(1, 0);
	for (int i = 1; i < 1000000; i++) {
		if (prime(i)) {
			v.push_back(v.back() + 1);
		} else {
			v.push_back(v.back());
		}
	}
	int n;
	while (cin >> n) {
		if (n == 1) {
			cout << 0 << endl;
		} else {
			cout << v[n] + 1 << endl;	
		}
	}
}