Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [31]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++: /*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp*/

#include <iostream>

using namespace std;

int main()
{
    int n;

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

        while (1 < n){
            int prime_flag=1;
            for (int j = n - 1; prime_flag && 1 < j; j--) {
                if(n % j==0){
                    prime_flag=0;
                }
            }
            count+=prime_flag;
            n--;
        }
        cout<<count<<endl;
    }
    return 0;
}

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

bool check(int in){
	for (int i = 3; i<=sqrt(in); i+=2){
		if (i != 5 && i % 5 == 0)	continue;
		if (in % i == 0)
			return false;
	}
	return true;
}

int PrimeNumber(int in, int start){
	int count = 0;
	if (in > 2)	count++;
	for (int i = start; i <=in; i+=2){
		if (check(i))	count++;
	}

	return count;
}

int main(){
	int in;
	int count250000 = PrimeNumber(250000, 3);
	int count500000 = count250000 + PrimeNumber(500000, 250001);
	int count750000 = count500000 + PrimeNumber(750000, 500001);

	while (cin >> in, !cin.eof()){
		if (in <= 250000)
			cout << PrimeNumber(in, 3) << endl;
		else if (in <= 500000)
			cout << count250000 + PrimeNumber(in, 250001) << endl;
		else if (in <= 750000)
			cout << count500000 + PrimeNumber(in, 500001) << endl;
		else
			cout << count750000 + PrimeNumber(in, 750001) << endl;
	}
}

C++: #include <iostream>

using namespace std;

int sang(int n,bool *s,int *p,int &m){
	m = 0;
	for(long i = 2; i<=n;i++){
		s[i] = 2;
	}
	for(long i = 2; i<=n; i++){
		if(s[i]){
			p[m++] = i;
			for(long j = i * i; j<= n ; j += i){
				s[j] = 0;
			}
		}
	}
	return m;
}
int main(){
	int test =0;
	bool s[100005];
	int n,p[100005],m;

	while(test <999999){
		cin>>n;
		sang(n,s,p,m);
		cout<<m<<endl;
		test++;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <limits>
#include <map>
#include <string>
using namespace std;

bool is_prime(int n){
for(int i=2;i*i<=n;i++){
if(n % i == 0) return false;
}
return n!=1;
}

int main(){
int n;


while(~scanf("%d",&n)){
int* table =  new int[n+1];
fill((int*)table,(int*)table+sizeof(table),1);
table[0]=0;

for(int i=1;i*i<=n;i++){
if(!is_prime(i)) {
for(int j=i;j<=n;j*=i){
table[j] = 0;
}
}
}
printf("%d\n",count(table,table+1000000,1));
}
}

C++: #include<iostream>
using namespace std;
int main(){
	int a[999999]={0,0,1,2},n,k=0;count=2;
	for(int i=4;i<999999;i++){
		for(int j=2;j*j<=i;j++){
			if(i%j==0)k++;
		}
		if(k==1)count++;
		a[i]=count;
		k=0;
	}
	while(cin>>n)cout<<a[n]<<endl;
	return 0;
}

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

int main() {
    const int num = 100000;
    vector<int> pnums(num);
    vector<bool> np(num);
    np[0] = np[1] = true;

    for(int i = 2; i < num; ++i) {
        pnums[i] = pnums[i - 1] + !np[i];

        if(!np[i]) {
            for(int j = i; j < num; j += i) {
                np[j] = true;
            }
        }
    }

    for(int n; cin >> n;)
        cout << pnums[n] << endl;

    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

bool isprime (int n){

	if (n == 0 || n == 1){
		return false;
	}else if (n == 2){
		return true;
	}else if (n % 2 == 0){
		return false;
	} // end if
	
	for (int i = 3; i <= sqrt(n); i+= 2){
		if (n % i == 0){
			return false;
		} // end if
	} // end for
		
	return true;
}

int main()
{
	
//	cut here before submit 
//	freopen("testcase.prime", "r", stdin);
	int res = 0;
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;
	vector <int> prime(n+1, 0);

	int i;
	int count = 1;
	prime[2] = count;

	for (i = 3; i <= n; ++i){
		if (isprime(i)){
			++count;
		} // end if
		prime[i] = count;
	} // end for
	res = prime[n];

	cout << res << endl; 

	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
 
 
// cin >>
// cin <<
bool isPrime(int x){
    if(x==2) return true;
    if(x<2||x%2==0) return false;
    int i=3;
    while(i<=sqrt(x*1.0)){
         if (x%i==0)return false;
        i= i+2;
    }
    return true;
}
int main(){
    int in[30]={};
    int out=0;
	int max=0;
	bool flag[1000002];
    for(int i=0;i<30;i++){
		cin >>in[i];
		if(i==0){
			max=in[i];
		}else{
			if(in[i]>max){
				max=in[i];
			}
		}
	}
	for(int j=0;j<max+1;j++){
		if(isPrime(j)==true){
			flag[j]=true;
		}else{
			flag[j]=false;
		}
    }
	
    for(int i=0;i<30;i++){
		out=0;
		for(int j=0;j<in[i]+1;j++){
			 if(flag[j]==true){  
				 out++;
			 }
		}
		if(out!=0){
		 cout <<out <<endl;
		}
    }
     
    return 0;
}

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

int a[1000000];

int main()
{
  int n;
  int count;

  for (int i = 2; i < 1000000; i++){
    a[i] = 1;
  }

  for (int i = 0; i * i < 1000000; i++){
    if  (a[i] == 1){
      for (int j = 2; j * i <= 100000; j++){
        a[j * i] = 0;
      }
    }
  }

  while (cin >> n){
    count = 0;
    for (int i = 0; i < 1000000; i++){
      if (a[i] == 1){
        count++;
      }
    }
  }

  cout << count << endl;

  return (1);
}

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

int main(){
	int n;
	int count;
	int ans;

	while (cin >> n){
		ans = 0;
		for (int i = 2; i <= n; i++){
			count = 0;
			for (int j = 2; j < i; j++){
				if (i % j == 0){
					count++;
				}
			}
			if (count == 0)ans++;
		}
		cout << ans << endl;

	}


	return 0;
}

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

int main(){
	
	int i, j, num;
	int* pT;
	
	while(cin>>num){
		int count=0;
		pT = new int[num];
		
		for(i=0; i<num; i++){
			pT[i] = 0;
		}
		
		pT[0] = 1;
		
		for(i=2; i<=(num/2); i++){
			for(j=2; i*j<=num; j++){
				if(pT[i*j-1]==0){
					pT[i*j-1] = 1;
				}
			}
		}
		
		for(i=0; i<num; i++){
			if(pT[i]==0){
				++count;
			}
		}
		
		delete[] pT;
		
		cout << count << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int prime(int);
int main(){
    int a,n;
    while ( cin >> a){
        n=0;
        for (int i=2;i<a;i++){
            if (prime(i)==0){
                n++;
            }
        }
        cout << n << endl;
    }
}


int prime(int x){
    if(x==2 || x==3 || x==5 || x==7)
        return 0;
    if(x%2==0)
        return 1;
    if(x%3==0)
        return 1;
    for (int i=5;i<=sqrt(x)+1;i+=6){
        if(x%i==0 || x%(i+2)==0)
            return 1;
    }
    return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int primes[999999];
bool marks[999999+2];

int sive(int n)
{
    int i,limit=sqrt(n)+1,j,total,x=0;

    for(i=1;i<=n;i++)
        marks[i]=1;
    marks[0]=0;


    for(i=2;i<=limit;i++)
    {
        for(j=i;j*i<=n;j++)
            marks[i*j]=0;
    }
    for(i=0;i<=n;i++)
    if(marks[i]==1)
        x++;
    return x;
}
int main()
{
    long long n;
    for(int i=1;i<=30;i++){
    cin>>n;

    cout<<sive(n)-1<<endl;
    }
    return 0;
}