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 := i - 1; j >= 1; j-- {
				if i%j == 0 && j != 1 {
					flag = true
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

C++: 
/* vo00_09.cpp */

#include <iostream>
using namespace std;

const int N = 1000000;
int prime[N];

void init();

int main()
{
	init();

	int n;
	while (cin >> n) {
		
		cout << prime[n] << '\n';

	}

	return 0;
}

void init()
{
	for (int i = 0; i < N; ++i) { prime[i] = 1; }

	prime[0] = prime[1] = 0;

	int count = 0;
	for (int i = 2; i < N; ++i) {
		if (prime[i]) {
			for (int j = i * 2; j < N; j += i) { prime[j] = 0; }
			count++;
		}
		
		prime[i] = count;
	}
}

C++: #include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	while (1) {
		int n;
		int count = 1;
		cin >> n;
		if (n == 1) {
			cout << 0 << endl;
		}
		else if (n == 2) {
			cout << 1 << endl;
		}
		else {
			for (int t = 3; t <= n; t += 2) {
				FOR(i, 2, t - 1) {
					if (t%i == 0) {
						break;
					}
					if (i == t - 1) {
						count++;
						break;
					}
				}
			}
			cout << count << endl;
		}
	}
	
	
	return 0;
}

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

int main() {
	int a;
	while (cin >> a, a) {
		int sosuu = 0;
		if (a > 1)sosuu++;
		if (a > 2)sosuu++;
		for (int b = 5; b <= a; b+=2) {
			for (int c = 3;; c+=2) {
				if (b%c==0)break;
				if ((c + 1)*(c + 1) > b) { sosuu++;   break; }
			}
		}
		cout << sosuu << endl;
	}
}

C++: #include<iostream>

using namespace std;

int main(){
	int n;
	bool p[1000000] = { true };
	int ans[1000000] = { 0 };
	p[0] = false;
	p[1] = false;

	for (int i = 2; i < 1000; i++){
		if (p[i]){
			for (int j = i*i; j < 1000000; j+=i){
				p[j] = false;
			}
		}
	}

	for (int i = 0; i < 1000000; i++){
		ans[i] += p[i];
	}

	while (cin >> n)
		cout << ans[n] << endl;

}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;

const int SIZE = 1000000;
bool is_prime[SIZE];
vector<int> primes;
int main()
{
	fill(is_prime, is_prime+SIZE, true);
	for (int i = 2; i < SIZE; ++i)
	{
		if (is_prime[i])
		{
			for (int j = 2*i; j < SIZE; j += i)
				is_prime[j] = false;
			primes.push_back(i);
		}
	}

	int n;
	while (scanf("%d", &n) != EOF)
		if (n < 2)
			puts("0");
		else
			printf("%d\n", upper_bound(primes.begin(), primes.end(), n) - primes.begin() - 1);

	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
        int n;
        int d; //素数を入れるための添字
        bool count; //割りきれるかどうかの判定
        int number[400000]; //素数を入れておく
        number[0] = 2;
        
        
 
                d = 0;
                for(int i = 3; i <= n; i++){
                        count = true;
                        for(int j = 0; j <= d; j++)
                                if(i % number[j] == 0)
                                        count = false;
                        if(count == true){
                                d++;
                                number[d] = i;
                        }
                
        cout << d+1 << endl;
        }
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<vector>
#include<cmath>
#define mem0(x) memset(x,0,sizeof(x))
#define memff(x) memset(x,0xff,sizeof(x))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repp(i,a,b) for(int i=a;i<=b;i++)
#define per(i,b,a) for(int i=b;i>a;i--)
#define perr(i,b,a) for(int i=b;i>=a;i--)
#define MAX_N 5050
#define MAX_M 5050
#define MAX_P 1000010
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
map<int,int> m;
const int INF=1<<29;
const int MOD=1e9+7;
int par[MAX_N];
int rank[MAX_N];
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int GCD(int a,int b){if(b==0) return a;return GCD(b,b%a);}
void init(int n){rep(i,0,n){par[i]=i;rank[i]=0;}}
int find(int x){return x==par[x]?x:par[x]=find(par[x]);}
void unite(int x,int y){x=find(x);y=find(y);if(x==y) return;if(rank[x]<rank[y]){par[x]=y;}else{par[y]=x;if(rank[x]==rank[y])rank[x]++;}}
bool same(int x,int y){return find(x)==find(y);}
struct node{int x,y;};
bool cmp(int x,int y){return x>y;}
bool ccmp(node x1,node x2){return x1.x>x2.x;}
LL mod_pow(LL x, LL n,LL mod){LL res=0;while(n>0){if(n&1) res=res*x%mod;x=x*x%mod;n>>=1;}return res;}
int prime[MAX_P];
bool is_prime[MAX_P];
int x;
int sieve(int  n)
{
    int p=0;
    repp(i,0,n)
    {
        is_prime[i]=true;
    }
    is_prime[0]=is_prime[1]=false;
    repp(i,2,n)
    {
        if(is_prime[i])
        {
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i)
            is_prime[j]=false;
        }
    }
    return p;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    while(~scanf("%d",&x))
    {
        printf("%d\n",sieve(x));
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
#define MAX 1000000
#define SQRTMAX 1000
void seive_prime(bool seive[])
{
	for(int i=2;i<=SQRTMAX;i++) {
		if(seive[i] == false) {
			for(int j=i*2;j<=MAX;j+=i) {
				seive[j]=true;
			}
		}
	}
}
int main() {
	int n;
	bool sieve[MAX+1] = {false};
	// エラトステネスの篩
	seive_prime(sieve);
	
	while(cin >> n) {
		int cnt = 0;
		for(int i=2;i<=n;i++) {
			if(sieve[i] == false)
				cnt++;
		}
		cout << cnt << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
 
int main(){
  bool prime[1000000] = {};
  int sum[1000000]; sum[0] = sum[1] = 0; sum[2] = 1;
  for(int i = 3 ; i < 1000000 ; i += 2 ){
    sum[i] = sum[i + 1] = sum[i - 1];
    if(!prime[i]){
      for(int j = i + i + i ; j < 1000000 ; j += i + i ){
        prime[j] = true;
      }
      sum[i]++;
      sum[i+1]++;
    }
  }
 
  int n;
  while(cin >> n){
    cout << sum[n] << endl;
  }
}

C++: #include <iostream>
#include <cstring>
using namespace std;
#define maxn 1000000

int  isprime(int n)
{
  
  bool prime[maxn];
  int p = 0;
  memset(prime,true,sizeof(prime));
  prime[0] = prime[1] = false;
  for(int i=2;i<=n;i++)
  {
    if(prime[i])
    {
      for(int j=2*i;j<=n;j+=i) prime[j] = false;
      p++;
    }
  }

  return p;
}

int main()
{

    int n;
    while(cin>>n)
    {
      cout<<isprime(n)<<endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cmath>
bool ifprime(int i);
int numbers[31];
int nn[31];
int num = 0;
int main()
{
	int n, count;
	bool ans;
	while ((scanf("%d", &n)) != EOF)
	{
		if (num > 0)
		{
			for (int i = 0; i <= num; i++)
			{
				if (n == numbers[i])
				{
					printf("%d\n", nn[i]);
					break;
				}
			}
		}
		else
		{
			count = 0;
			for (int i = 2; i <= n; i++)
			{
				ans = ifprime(i);
				if (ans == true)
				{
					++count;
				}
			}
			printf("%d\n", count);
			numbers[num] = n;
			nn[num] = count;
			num++;
		}
	}

	return 0;
}
bool ifprime(int i)
{
	int m = (int)sqrt(i);
	for (int j = 2; j <= m; j++)
	{
		if (i% j == 0)
		{
			return false;
		}
	}
	return true;
}