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 <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>

#define sf scanf
#define pf printf

using namespace std;

const int Maxn = 1000010;
int prime[Maxn];
int flag[Maxn];
int cnt ;
void _init()
{
    for(int i = 2;i < Maxn;i ++)
    {
        if(flag[i] == 0)
        {
            prime[cnt++] = i;
            for(int j = i * 2;j < Maxn;j += i)
                flag[j] = 1;
        }
    }
}
int Find(int n)
{
    int l = 0,r = cnt;
    while(l <= r)
    {
        int mid = (l + r) / 2;
        if(prime[mid] <= n)
            l = mid + 1;
        else
            r = mid - 1;
    }
    return l;
}
int main()
{
    _init();

    int n;
    while(~sf("%d",&n))
    {
        pf("%d\n",Find(n));
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main( void )
{
	int n;
	cin >> n;

	if ( n <= 0 )
		cout << "0" << endl;
	
	vector <bool> p(n+1, true);

	p[0] = p[1] = false;
	for ( int i = 4; i <= n; i += 2 )
	{
		p[i] = false;
	}

	for ( int i = 3; 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 <stdio.h>
const int MAX_V = 1000000; // 100???????????????????f???????¢\????°???¬?????
int prime[MAX_V+1] ,cnt[MAX_V+1] = {0};
int main(){
		int k,i,n; // 1????????f???????C0????????f????????????????????¢
	for(i = 2; i <= MAX_V; i++) {
		prime[i] = 1; // 2???????£????f????????????°??????¨
	}
	for(i = 2; i <= MAX_V; i++) {
		cnt[i] = cnt[i-1];
		//printf("")
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0; // ???f??????2???{???????£????{?????????f????????????????????¢
			}
			cnt[i]++;
		}
	}
	while(scanf("%d",&n) != EOF){
		printf("%d\n",cnt[n]);
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
    int i,j,cnt,n;
    while(scanf("%d",&n)!=EOF){
        cnt=0;
        for(i=2;i<=n;i++){
            for(j=2;j<=i;j++){
                if(i==j){
                    cnt++;
                }
                if(i%j==0){
                    break;
                }
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}

C++:  #include <iostream>
using namespace std;
int main(){
	long long n , i , j , ans , num ;
	while(cin>>n){
		ans=0;
		for( i=2 ; i<=n ; i++ ){
			num=0;
			for( j=2 ; j<=n ; j++ ){
				if( i%j ==0 )
					num++;
			}
			if( num<2 )
				ans++;
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <list>
#include <vector>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <sstream>
#include <complex>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <limits>
#include <numeric>
#include <cmath>
#include <functional>
#include <queue>
#include <cstring>

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;

#define FORE(k,a,b) for(int k=(a); k <= (int)(b); ++k)
#define FOR(k,a,b) for(int k=(a); k < (int) (b); ++k)

#define pb push_back
#define mp make_pair
#define sfi(a) scanf("%d",&a)
#define pfi(a) printf("%d\n",&a)

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<uint> uvi;
typedef vector<uvi> uvvi;
typedef vector<vd> vvd;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vii> vvii;
typedef pair<uint,uint> uu;
typedef map<string, int> msi;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define FOR_IT(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define contains(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

#define MAX 100000000
#define LMT 10000

int a[10000000];

int main()
{
	int i,j,n,cnt=0;
	while(scanf("%d",&n)==1)
	{
		cnt=0;

		memset(a,0,sizeof(a));

		for(i=2;i<=n;++i){
			if(a[i]==0){
                for(j=i*i;j<=n;j+=i)
                a[j]=-1;

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

C++: #include <iostream>
#include <cstdio>
using namespace std;
const int MAX_N = 1000000; // いくつまで調べるか
bool prime[MAX_N + 1]; // 添字が素数ならtrue、それ以外はfalse
void sieve()
{
  prime[0] = prime[1] = false; // 例外処理
  // 配列prime の初期化
  for(int i = 2; i <= MAX_N; ++i)
    prime[i] = true;
  // 素数でないものを調べる
  for(int i = 2; i <= MAX_N; ++i)
    if(prime[i])
      for(int j = i * 2; j <= MAX_N; j += i)
	prime[j] = false;
	}

int is_prime(int n)
{
  return prime[n];
  }

/*bool is_prime(int n)
{
  if(n == 1)return false;
  for(int i = 2; i < n; ++i)
    if(n % i == 0)return false;
  return true;
  }
*/
int main()
{
  //sieve();
  int a;
  while(cin >> a){
    //cin >> a;
    //if(a==EOF)return 0;
    int count=0;
    //int tmp;
    for(int i=1;i<=a;i++){
      if(is_prime(i))count++;
    }
    printf("%d\n",count);
  }
}

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

using namespace std;

int main()
{
	int i,j;
	char array[1000010];
	
	for(i=0;i<1000001;i++)
		array[i]='1';
	
	array[0]=array[1]='0';
	
	for(i=0;i<1000001;i++)
	{
		if(array[i]=='1')
		{
			for(j=2;i*j<1000001;j++)
				array[i*j]='0';
		}
	}
	
	vector<int> ans;
	
	for(i=0;i<1000001;i++)
	{
		ans.push_back(0);
	}
	for(i=1;i<1000001;i++)
	{
		ans[i]+=ans[i-1];
		ans[i]+=(int)array[i]-48;
	}
	
	int inp;
	for(;cin >> inp;)
	{
		cout << ans[inp] << endl;
	}
}