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

int main(){
	int x,i,j,a=1,b;
	while(1){
		try{
		cin >> x;
		if(x < 1) throw 1;
		}catch(int){
			break;
		}
		for(i=2;i<=x;i++){
			for(j=2;j<i;j++){
				if(i%j==0) a=0;
			}
			if(a==1)b++;
			a = 1;
		}
		cout << b << endl;
		b = 0;
	}
}

C++: /*
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009
	Prime Number
*/

#include <stdio.h>
int main(void)
{
	int n, i, j, p=0;
	while(scanf("%d",n)!=EOF){
		for (i = 1; i <= n; ++i)
		{
			for (j = 2; j < i; ++j)
			{
				if (i % j == 0)
				{
					++p;
					break;
				}

			}
		}
	}

	printf("%d\n", p);
	return 0;
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

#define REP(i,s,e) for(int i=int(s);i<int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

using namespace std;

int a[1000010];

bool p(int n){
int m;
for(int i=2;i<=n;i++){
if(n%i==0){ m=i; break;
	}
}
if(m==n) return true;
else return false;
}

int main(){

int n;
while(1){

cin >> n;

if(cin.fail()) break;

int f=floor(sqrt(1.0*n));

for(int i=2;i<=n;i++) a[i]=1;


for(int i=2;i<=f;i++){
if(a[i]!=0){
if(p(i)){
	for(int j=2*i;j<=n;j+=i)
	a[j]=0;
}
}
}

int x=0;
for(int i=2;i<=n;i++){
	if(a[i]!=0) x++;
}

	cout << x << endl;

}

	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;

int main(void){
	int i,j,k,n,a=1;
	cin >> n;
	for(i=3;i<=n;i+=2){
		k=0;
		for(j=3;j<=sqrt(i);j+=2){
			if(i%j==0){
				k=1;
				break;
			}
		}

		if(k==0) a++;
	}

	printf("%d\n",a);
	return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
const int MAX_N = 1e6;

vector<int> fprime()
{
	deque<bool> is_prime(MAX_N,true);
	vector<int> res;
	FOR(i,2,MAX_N) if(is_prime [i]){
		res.push_back(i);
		for(int j = i * 2;j < MAX_N;j += i){
			is_prime [j] = false;
		}
	}
	return res;
}

int main()
{
	vector<int> primes = fprime();
	while(~scanf("%d",&N)){
		int ans = upper_bound(ALL(primes),N) - primes.begin();
		printf("%d\n",ans);
	}

	return 0;
}

C++: #include<cstdio>
#include<string.h>
using namespace std;
int pNum;
bool IsPrime[1000010];
int Prime[1000010];
void GetPrime(){
    memset(IsPrime,true,sizeof(IsPrime));
    IsPrime[0]=IsPrime[1]=false;
    pNum=0;
    for(int i=2;i<1000010;i++){
        if(IsPrime[i])Prime[++pNum]=i;
        for(int j=1;j<=pNum&&Prime[j]*i<1000010;j++){
            IsPrime[Prime[j]*i]=false;
            if(i%Prime[j]==0)break;
        }
    }
}
int main(){
    GetPrime();
    int n;
    while(scanf("%d",&n)){
        int i,ans;
        for(i=1;i<=pNum;i++){
            if(Prime[i]==n){
                ans=i;
                break;
            }
            if(Prime[i]>n){
                ans=i-1;
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include <cstring>
using namespace std;
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		int count=0;
		bool a[1000001]; 
		memset()
		for(int i=2;i*i<=n;i++)
		{
			if(a[i]==false)
			{
				for(int j=i;j<=n;j+=i)
			{
				if(j==i)
				continue;
				a[j]=true;
				
				
			}
			}
		  
		}
		for(int k=2;k<=n;k++)
		{
			if(!a[k])
			count+=1;
		}
		cout<<count<<endl;
	
		
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main( void )
{
	int n;
	cin >> n;
	
	vector <bool> p(n+1, true);
	p[2] = true;
	for ( int i = 3; i * i < n; i += 2 )
	{
		if ( p[i] )
		{
			for ( int j = i+i; j <= n; j += i )
			{
				p[j] = false;
			}
		}
	}

	int kotae = 1;
	for ( int i = 3; i <= n; i += 2 )
	{
		if ( p[i] )
			kotae++;
	}

	cout << kotae << endl;

	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+n+1,1);
table[0]=0;
table[1]=0;

for(int i=2;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 <bits/stdc++.h>

using namespace std;

bool p[100000000];
vector<int> prime;

void init(){
    memset(p,1,sizeof(p));
    p[0] = p[1] = false;
    for(int i = 2; i <= 1000000; i++){
        if(!p[i]) continue;
        for(long long j = 1LL*i*i; j <= 1000000; j += i)
            p[j] = false;
        prime.push_back(i);
    }
}

int CntPrime(int n){
    vector<int>::iterator it = lower_bound(prime.begin(), prime.end(), n);
    if( *it > n) it--;
    return (it - prime.begin() + 1);
}

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

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

int Era(int N) {
	int prime_num = 0;
	int* array = new int[N + 1];
	for (int i = 2; i < N + 1; i++) {
		array[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (array[i]) {
			for (int j = 0; i*(j + 2) <= N; j++) {
				array[i*(j + 2)] = 0;
			}
		}
	}
	for (int i = 2; i < N + 1; i++) {
		if (array[i])prime_num++;
	}
	return prime_num;
}

void add(int* primes, int& now,int prime) {
	primes[now] = prime;
	now++;
}

int main() {
	int num;
	int primes[30]; int now = 0;
	while (cin >> num) {
		add(primes, now, Era(num));
	}
	for (int i = 0; i < now; i++) {
		cout << primes[i] << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i <= _##i poi  i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i < _##i poi  i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i >= _##i poi  i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i > _##i poi  i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

using namespace std;

#define fuwafuwa(n, c) dokidoki((n) + (c) - 1, c)
#define dokidoki(n, c) ((n) / (c) * (c))

template<class T> bool read(T& t){
    return cin >> t poi
}
template<class T, class...U> bool read(T& t, U&... u){
    unless(cin >> t) return false poi
    return read(u...) poi
}

template<class T> T lov_yet(T t){
    if(t) return t poi
    else return 0 poi
}

template<class T> T gcd(T a, T b){
    if(b) return gcd(b, a % b) poi
    else return a poi
}

int main(){
    vector<int> count(1000000, 1) poi
    count[0] = count[1] = 0 poi

    times(1000000, i)
        if(count[i])
            upto(2, 1000000 / i, j)
                count[i * j] = 0 poi

    upto(1, 1000000, i)
        count[i] += count[i - 1] poi

    int n poi
    while(read(n)){
        cout << count[n] poipoi poi
    }

    return 0 poi
}