Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		flag := false
		count := 0

		for i := 2; i <= num; i++ { //1を除く入力値以下の数字
			for j := 2; j < i-1; j++ {
				if i%j == 0 && j != 1 {
					flag = true
					//fmt.Println(i, "/", j)
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

C++: #include <stdio.h>
#include <string>
#include <iostream>

//using namespace std;

int sosuu(int n);

int main(){
    int n = 0;
    
    while(scanf("%d",&n)!=EOF){
        int temp = 0;
        if(n==1){
            printf("%d",0);
        }else{
            for(int i=2; i<=n; i++ ){
                temp+=sosuu(i);
                if(i!=2){
                    i++;
                }
            }
            printf("%d\n",temp);
        }
    }
    
    
}

int sosuu(int n){
    for(int i=2; i<n/2; i++){
        if(n%i == 0){
            return 0;
        }
        if(i!=2){
            i++;
        }
    }
    return 1;
}

C++: #include<stdio.h>
#define MAX_N 100000

int main(void){
	int prime[MAX_N],is_prime[MAX_N+1];
	int n,p,i,j;
 

	while(scanf("%d",&n)!=EOF){
	
		p=0;
	
		for(i=0;i<n;i++){
			is_prime[i]=1;	//f»èzñÌú»
		}
	
		is_prime[0]=0;
		is_prime[1]=0;	//0Æ1ÍfÅÍÈ¢ÌÅ\ßæè­
	
		for(i=2;i<=n;i++){
			if(is_prime[i]==1){
				prime[p++]=i;
				for(j=2*i;j<=n;j=j+i){
					is_prime[j]=0;
				}
			}
		}
		printf("%d\n",p);
	}
	return 0;
}

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

int main(){
    int n, i;
    while(scanf("%d", &n) != EOF){
        int cnt = 0;
        for(; n>1; n--){
            for(i=2; i<=sqrt(n)+1; i++){
                if(n%i == 0) break;
            }
            if(i>sqrt(n)) cnt++;
        }
    cout << cnt <<endl;
    }
}

C++: //Prime Number
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	const int MAX = 1000000;
	bool isPrime[MAX];
	for(int i = 0; i < MAX; i++) {
		isPrime[i] = true;
	}
	
	for(int i = 2; i*i < MAX; i++) {
		if(isPrime[i]) {
			for(int j = i*i; j < MAX; j += i) {
				isPrime[j] = false;
			}
		}
	}
	
	int n;
	while(cin >> n) {
		int count = 0;
		for(int i = 2; i <= n; i++) {
			if(isPrime[i]) count++;
		}
		cout << count << endl;
	}
	
	return 0;
}

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

using namespace std;

int main(){
        int prime[1000000];
        bool is_prime[1000000];
        int i=2,j=2,n,count=0;
        while(scanf("%d",&n) != EOF){
                int p = 0;
                for(i = 0;i <= n; i++){
                        is_prime[i] = true;
                }
                is_prime[0]=is_prime[1]=false;
                for(i = 2; i<=n;i++){
                        if(is_prime[i]){
                                prime[p++] = i;
                                for(j = 2*i; j <= n; j+=i) is_prime[j] = false;
                        }
                }
                cout << p << endl;
        }
        return 0;
}

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=1;

        if(n%2==0){
            n--;
        }
        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-=2;
        }
        cout<<count<<endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX 1000000

int main(){
	bool p[MAX+1];
	int num,answer;
	p[0] = false;
	p[1] = false;
	for(int i=2 ; i<=MAX ; i++){
		p[i] = true;
	}
	for(int i=2 ; i<=sqrt(MAX)+1 ; i++){
		if(p[i]==1){
			for(int j=i*2; j<=MAX; j=j+i){
				p[j] = false;
			}
		}
	}
		
	while( scanf("%d" , &num) != EOF ){	
		answer = 0;	

		for(int i=0; i<=num; i++){
			if(p[i]){
				answer++;
			}
		}
		printf("%d\n", answer);
	}
}

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

int main() {
	int n, ans; bool check;
	while (cin >> n) {
		ans = 0;
		for (int i = 1; i <= n; i++) {
			if (i <= 3) { if (i != 1) ans++; continue; }
			if (i % 2 == 0 || i % 3 == 0) continue;
			if (i % 6 != 1 && i % 6 != 5) continue;
			check = true;
			for (int j = 5; pow(j, 2) <= i; j += 6) {
				if (i % j == 0 || i % (j + 2) == 0) check = false;
				if (check == false) break;
			}
			if (check == true) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
	
	int p[168],l=0,n;
	
	for(int i=2;i<1000;i++){
		int k=0;
		for(int j=2;j<=sqrt(i);j++)if(i%j==0&&i/j!=1)k=1;
		if(k==0){p[l]=i; l++;}
	}
	
	while(cin>>n){
		l=0;
		for(int i=2;i<=n;i++){
			int k=0;
			for(int j=0;j<168;j++)if(i%p[j]==0&&i/p[j]!=1)k=1;
			if(k==0)l++;
		}
		cout<<l<<endl;
	}
	
	return 0;
}

C++: #include <cstdio>
#define MAX 1000000

int main(){
	int n;
	bool c[MAX]={true};
	int t[MAX];t[0] = 0;
	for(int i = 2;i < MAX;i++){
		for(int j = i;i*j < MAX;j++){
			c[i*j-1] = true;
		}
	}
	for(int i = 1;i < 15;i++){
		if(c[i])t[i]=t[i-1];
		else t[i] = t[i-1]+1;
	}
	while(scanf("%d", &n)){
		printf("%d\n", t[n-1]);
	}
	return 0;
}

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

int main()
{
        long long max;
        vector<long> pn;
        bool npn[1000001];
        npn[0] = npn[1] = true;


        while(cin >> max){
                for(long j=2;j<=999999;j++) npn[j] = false;
                for(long i=2;i<=max;i++){
                        if(npn[i]) continue;
                        pn.push_back(i);
                        for(long j=i*1;j<=max;j+=i)npn[j] = true;
                }

                cout << pn.size() << "\n";
                pn.clear();
        }

        return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  bool is_prime[1000000];
  REP1(i, 999999) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i * i <= 999999; ++i) {
    if (is_prime[i]) {
      for (int j = 2; i * j <= 999999; ++j) is_prime[i * j] = false;
    }
  }
  int sum[1000000];
  sum[0] = 0;
  REP1(i, 999999) sum[i] = sum[i - 1] + is_prime[i];
  int n;
  while (cin >> n) cout << sum[n] << endl;
  return 0;
}

C++: #include<iostream>

#define LIM 1000000
using namespace std;

int main(){
  bool num_map[LIM];
  int in_num,prime_count;
  for(int i=0;i<LIM;i++){
    num_map[i]=1;
  }
  
  for(int i=2;i<LIM;i++){
    if(num_map[i]==1)
      for(int j=i*2;j<LIM;j+=i){
	num_map[j]=0;
      }   
  }
  while(cin>>in_num){
    prime_count = 0;
    //    cin>>in_num;
    //cout<<in_num<<endl<<endl;
    for(int i=2;i<=in_num;i++){
      if(num_map[i]==1)
	prime_count++;
    }
    cout<<prime_count<<endl;  
  }
  
}

C++: #include<stdio.h>
int main(){
	long int a,b,n;
	long int p[80000];
	p[0]=2;
	n=1;
	for(a=3;a<1000000;a++){
		for(b=0;b<n;b++){
			if(a%p[b]==0){break;}
			if(a<p[b]*p[b]){
				p[n]=a;
				n++;
				break;
			}
		}
	}
	for(;;){
		if(scanf("%ld",&a)==EOF){break;}
		n=0;
		while(a>=p[n]){
			n++;
		}
		if(a<2){n=0;}
		printf("%ld\n",n);
	}
	return 0;
}