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++: /***********************************************************
エストラテネスの篩
O(n log n)よりははやい.
 ***********************************************************/

#include <vector>

std::vector<bool> prime_table(int N){
    std::vector<bool> is_prime(N + 1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= N; i++){
        if (is_prime[i]){
            for (int j = i * 2; j <= N; j += i) is_prime[j] = false;
        }
    }
    return is_prime;
}

std::vector<int> compute_primes(int N){
    std::vector<bool> is_prime = prime_table(N);
    std::vector<int> primes;
    for (int i = 0; i < N + 1; i++) if (is_prime[i]) primes.push_back(i);
    return primes;
}


// solution for http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp

#include <vector>
#include <iostream>

using namespace std;

int main(){
    int n;
    while(cin >> n){
        vector<int> primes = compute_primes(n);
        cout << primes.size() << endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    int x;
    int i, j;
    int p[999999] = {};
    p[2] = 1;
    for (i = 3; i < 1000000; i++) {
        for (j = 2; ; j++) {
            if (!(i % j)) {
                break;
            } else if (j > sqrt(i)) {
                p[i] = 1;
                break;
            }
        }
    }
    while (scanf("%d", &x) != EOF) {
        j = 0;
        for (i = 0; i <= x; i++) {
            j += p[i];   
        }
        printf("%d\n", j);
    }
    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 < 50; 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 <stdio.h>
#include <string.h>
int main(void){
    int n=999999,a,b,c;
    short x[1000000];
    memset(x,0,sizeof(x));
    for(a=2,c=0;a<=n;a++){
        if(x[a]){x[a]=c;continue;}
        x[a]=++c;
        for(b=a*2;b<=n;b+=a)x[b]=-1;
    }
    while(~scanf("%d",&n)){
        printf("%d\n",x[n]);
    }
    return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int prime[1000000];
int main(){
    int n,ans=0;
    for(int i=0;i<1000000;i++)
        prime[i]=1;
    prime[1]=0;
    prime[2]=1;
    for(int i=1;i<1001;i++){
        if(prime[i]==1){
            for(int j=i+1;j<1000000;j++){
                if(j%i==0)
                    prime[j]=0;
            }
        }
    }
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        if(prime[i]==1)
        ans++;
    }
    printf("%d",ans);
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#define pb push_back
using namespace std;

int primes(int n) {
  int cnt=0;
  vector<bool> pri(n+1,false);
  for(int i=2;i<=n;i++) {
    if(pri[i]==false) {
      cnt++; pri[i]=true;
      for(int j=i*2;j<=n;j+=i) {
	pri[j]=true;
      }
    }
  }
  return cnt;
}


main() {
  int n;
  while(cin>>n) {
    cout << primes(n) << endl;
  }
}

C++: import java.util.Scanner;

public class Main {

    //?¨????????????????
    public int kazu(int num){

        //?´???°??????????????????????????°????????????
        int count = 0;
        //?´???°?????????????????????
        boolean result;

        for(int i = 2; i < num; i++){
            //?´???°??§????????¨?????????????????????
            result = true;
            for(int j = 2; j < i; j++){
                if(i % j == 0){
                    //?´???°???????????´????´???°??§??????
                    result = false;
                    break;
                }
            }
            //??????????????§?????????????´???°??¨??????????????????
            if(result)count++;
        }
        return count;
    }

    public static void main(String[] args){
    	Scanner sc = new Scanner (System.in);
        //?????????????????°???????´?????????????
        
        Main2 sosu = new Main2();
        int num = sc.nextInt();
        while(num < 100000){
        	System.out.println(sosu.kazu(num));
        	num = sc.nextInt();
        	
        }


    }

}

C++: include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1],sum[MAX_V+2]={0};
int main(){
  int n;
  for(int i = 2;i <= MAX_V;i++){
    prime[i] = 1;
  }
  for(int i = 2;i * i <= MAX_V;i++){
    if(prime[i]){
      for(int k = 2* i;k <= MAX_V;k += i)
      prime[k]=0;
    }
  }
  for(int i = 2;i < MAX_V;i++){
    sum[i] +=sum[i-1]+prime[i];
  }
  while(scanf("%d",&n)!=EOF){
    printf("%d\n",sum[n]);
  }
  return 0;
}

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

using namespace std;

vector<int> make_prime_list(int max_num){
    vector<bool> is_prime_list(max_num+1, true);
    for(int i=2; i <= sqrt(max_num); i++){
        if(is_prime_list[i]){
            for(int j=2; i*j <= max_num; j++){
                is_prime_list[i*j] = false;
            }
        }
    }

    int count = 0;
    vector<int> prime_list(max_num+1, 0);
    for(int i=2; i <= max_num; i++){
        if(is_prime_list[i]){
            count++;
        }
        prime_list[i] = count;
    }

    return prime_list;
}

int main(void){
    int input;

    vector<int> prime_list = make_prime_list(999999);

    while(cin >> input){
        cout << prime_list[input] << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 1e6+7;
int prime[maxn];
bool is_prime[maxn];
int n,p=-1;

void Eular()
{
    for(int i=1;i<=maxn-7;i++)
        is_prime[i]=true;
    for(int i=2;i<=maxn-7;i++)
    {
        if(is_prime[i])
            prime[++p]=i;
        for(int j=0;j<=p && i*prime[j] <= maxn-7;j++)
            is_prime[i*prime[j]]=false;
    }
}

int main()
{
    Eular();
    while(~scanf("%d",&n))
    {
        int i=0,ans=0;
        while(i<p && prime[i]<=n) i++,ans++;
        printf("%d\n",ans);
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a; i ++)
#define loop(i,b,a) for(int i = b ; i < a; i ++)
const int MAX = (1e8);
bool p[MAX];
void isPrime(){
  rep(i,MAX)p[i] = true;
  p[0] = p[1] = false;
  loop(i,2,MAX){
      if(p[i]){
      for(int j = i + i ; j < MAX ; j += i){
	p[j] = false;
      }
    }
  }
}

int main(void){
  isPrime();
  int n;
  while(cin>>n){
  int i = n-1;
  while(!p[i--]);
  cout<<++i<<' ';
  i = n + 1;
  while(!p[i++]);
  cout<<--i<<endl;
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream> 
#include <math.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std; 
int main(){
	int N;
	double p = std::log2(N);
	while (cin >> N){
		int sum =0;
		cout << N*p << endl;
	}
	return 0;
}