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

C++: #include <iostream>
#include <cstring>
#define MAX 46656
#define LMT 216
#define LEN 4830
#define RNG 100032
#define sq(x) ((x)*(x))
#define mset(x,v) memset(x, v , sizeof(x))
#define chkC(x,n) (x[n >> 6] & (1 << ((n >> 1) & 31)))
#define setC(x,n) (x[n >> 6] |= (1 << ((n >> 1) & 31)))
using namespace std;
unsigned base[MAX/64], segment[RNG/64], primes[LEN];

void sieve()
{
    unsigned i, j, k;
    for (i = 3; i < LMT; i += 2)
    {
        if (!chkC(base, i))
        {
            for (j = i * i, k = i << 1; j < MAX; j += k)
                setC(base, j);
        }
    }
    for (i = 3, j = 0; i < MAX; i += 2)
    {
        if (!chkC(base, i))
            primes[j++] = i;
    }
}

int main()
{
    int n,i,c;
    sieve();
    while(cin>>n)
    {
        if(n==0 || n==1)
        {
            cout<<1<<endl;
            continue;
        }
        c=1;
        for(i=0;i<MAX;i++)
            if(primes[i]<=n) c++;
            else break;
        cout<<c<<endl;
    }
}

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

int main(){
	int n,k,p[100000],s,i,j;
	k=1;
	p[0]=2;
	for(i=3;i<99999;i+=2){
		s=0;
		for(j=0;j<k;j++){
			if((i%p[j])==0){
				s++;
			}
		}
		if(s==0){
			p[k]=i;
			k++;
		}
	}
	
	while(cin >> n){
		if(n<100000){
			for(i=0;n>=p[i];i++){
			}
			cout << i <<"\n";
		}
		else{
			n=n/log(n);
			cout << n <<"\n";
		}
	}
return 0;
}

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

int main()
{
	int n, i,j,k,cnt;
	while (scanf("%d", &n) != EOF)
	{
		cnt = 0;
		if (n <= 1)
		{
			printf("0\n");
			continue;
		}
		if (n == 2)
		{
			printf("1\n");
			continue;
		}
		if (n <= 4)
		{
			printf("2\n");
			continue;
		}
		for (j = 5; j <= n; j+=2)
		{
			k = 0;
			for (i = 3; i <= sqrt(n*1.0); i += 2)
			{
				if (j%i == 0)
				{
					k = -1;
					break;
				}
			}
			if (k == -1)continue;
			cnt++;
		}
		printf("%d\n", cnt + 2);
	}
}

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

int main(){
	int n,t;
	while(scanf("%d",&n)!=EOF){
		int c=1;
		for(int i=3;i<=n;i+=2){
			int j=3;
			t=1;
			while( j <= sqrt(i) ){
				if(i%j==0){
					t=0;
				}
				j+=2;
			}
			if(t!=0){
				t=1;
			}
			if(t){
				c++;
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

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

#define Max 1000000

int isPrime[Max];

int main(){
    int num;
    int i,j;

    //配列の初期化
    isPrime[0] = isPrime[1] = 0;
    for(i = 2; i < Max; ++i){
        isPrime[i] = 1;
    }

    for(i = 2; i < Max; i++){
        if(isPrime[i] == 1){
            for(j = 2; i * j <= Max; ++j){
                isPrime[i * j] = 0;
            }
        }
    }

    while(cin >> num){
        int count = 0;
        for(i = 2; i <= num; ++i){
            if(isPrime[i] == 1){
                count++;
            }
        }
        cout << count << endl;
    }
}

C++: /*
Volume0-0009
*/
#include <stdio.h>
#include <stdlib.h>

#define N 999999
#define M (999999/2)
#define TRUE (char)(0==0)
#define FALSE !TRUE
#define BUFLEN 1024

int syserr(char *str)
{
  fputs(str, stderr);
  exit(-1);
}

int main(int argc, char *argv[]){
  char *f;
  if ((f = (char *)malloc(M*sizeof(char)))==NULL)
    syserr((char *)"malloc");

  for (int i=0; i<M; i++){
    f[i] = TRUE;
  }
  for (int i=3; i<N; i+=2) {
    if (f[i/2-1] == TRUE ) {
      for (int j=i+2*i; j<N; j+=2*i){
	f[j/2-1] = FALSE;
      }
    }
  }
  int x = 1;
  for (int i=3; i<N; i+=2) {
    if (f[i/2-1]) {
      x = x + 1;
    }
    f[i/2-1]=x;
  }
  char buf[BUFLEN];
  while (fgets(buf,BUFLEN, stdin) != NULL){
    int n = atoi(buf);
    int m=0;
    if (n==2){
      m = 1;
    } else if (n % 2 == 0) {
      m = f[(n-1)/2 - 1];
    } else {
      m = f[n/2 - 1];
    }

    printf("%d\n", m);
  }

  exit(0);
}

C++: #include <iostream>
#define N 100000
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void)
{
    bool a[N+1];
    int prime[N], n;
    rep(i,N+1)
    {
        a[i] = true;
    }
    a[0] = a[1] = false;
    for(int i=2;i*i<=N;i++)
    {
        if(a[i])
        {
            prime[i] = prime[i-1] + 1;
            for(int j=i*i;j<N;j+=i)
                a[j] = false;
        }
        else
            prime[i] = prime[i-1];
    }

    while(cin >> n)
        cout << prime[n] << endl;
    
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
	bool a[600001];
	while(!cin.eof()){
		int n;
		cin >> n;

		for(int i = 2; i <= n; i++){
			a[i] = true;
		}

		for(int i = 2; i * i <= n; i++){
			if(!a[i]) continue;
			for(int j = i + 1; j <= n; j++)
				if(!(j % i)){
					a[j] = false;
				}
		}

		int ans = 0;
		for(int i = 2; i <= n; i++)
			if(a[i]){
				ans++;
			}
		cout << ans << endl;
	}
			
	return 0;
}

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


using namespace std;


int main(){
  int n;
  //?´???°???true,                                                                    
  bool flag = false;

  while(cin >> n){
    int cnt=0;
    //cout << n << endl;                                                           
    //    sqrt_n = sqrt(n);                                                        
    for(int i=2;i<=n;i++){
      flag = false;
      //?´???°?????????????????§??????                                                       
      for(int j=2;j<=sqrt(i);j++){
        //      cout << i << " " << j << endl;                                     
        //cout << j << endl;                                                       
        if(i%j==0){
          flag = true;
          //cout << i%j << endl;                                                   
          break;
        }

      }
      if(flag){continue;}

      cnt++;
      //cout << "last: " << i << endl;                                             
    }
    //cout << "cnt: " << cnt << endl;                                              
    cout << cnt << endl;

  }
}

C++: // AOJ 009

#include <iostream>
#define MAX_NUMBER 50 //1000000
using namespace std;

bool isPrime[MAX_NUMBER];

void SetFalseToMultiples (int prime) {
	for (int i = prime*2; i < MAX_NUMBER;i+=prime) {
		isPrime[i] = false;
	}
	return;
}	

int CountPrimes(int n) {
	int count = 0;
	for (int i = 1;i <= n;i++) {
		if (isPrime[i]) count++;
	}
	return count;
}

int main() {
	for (int i = 0;i < MAX_NUMBER;i++) {
		isPrime[i] = true;	
	}
	isPrime[1] = false;
	
	for (int i = 1;i < MAX_NUMBER;i++) {
		if (isPrime[i]) {
			SetFalseToMultiples(i);
		}
	}
	int n;
	while (cin >> n) {
		cout << CountPrimes(n) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>

#define MAX 999999

using namespace std;


int main(){
	int n = 0;
	int count;
	bool flag = false;
	vector<int> sosu;
	sosu.push_back(0);
	sosu.push_back(0);
	sosu.push_back(1);

	count = 1;
	for(int i = 3; i <= MAX; i += 2){
		for(int j = 3; j * j <= i; j += 2){
			if(i % j == 0){
				flag = true;
				break;
			}
		}
		if(flag != true){
			count++;
		}
		else{
			flag = false;
		}
		sosu.push_back(count);
		sosu.push_back(count);
	}
	

	while(cin >> n){
		cout << sosu[n] << endl;	
	}

	return 0;
}