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 "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

bool isprime[1000000];
int ans[1000000];

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	rep(i, 0, 1000000)isprime[i] = true;
	isprime[0] = false;
	isprime[1] = false;
	ans[0] = ans[1] = 0;
	int n = 0;
	rep(i, 2, sqrt(1000000) + 1)
	{
		if (isprime[i])
		{
			for (int j = 2 * i; j < 1000000; j += i)
			{
				isprime[j] = false;
			}
		}
	}
	rep(i, 2, 1000000)
	{
		if (isprime[i])
		{
			n++;
		}
		ans[i] = n;
	}

	int N;
	while (cin >> N)
	{
		cout << ans[N] << endl;
	}

	return 0;
}

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

using namespace std;
#define MAX_NUM 1000010


void do_calc(int *numPrime){
  for(int i=2;i<=MAX_NUM;i++){
    bool flag = false;

    for(int j=2;j<=sqrt(i);j++){
      if(i%j==0){
	flag = true;
	break;
      }
    }
      
    if(flag){
      numPrime[i] = numPrime[i-1];
      continue;
    }else{
      numPrime[i] = numPrime[i-1] + 1;
    }
  }
}
  


int main(){
  int n;
  int numPrime[MAX_NUM];

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

C++: #include<memory.h>
#include<cstdio>
const int maxn=100000;
int x;
bool isPrime[maxn];
void generateprime()
{

    memset(isPrime,true,sizeof(isPrime));
    for(int i=2;i<maxn;i++)
        for(int j=2;j*i<maxn;j++)
        isPrime[j*i]=false;
}

int main()
{
    generateprime();
    while(scanf("%d",&x)!=EOF)
    {   int res=0;
        for(int i=2;i<=x;i++)
            if(isPrime[i])
            {
            res=res+1;}
        printf("%d\n",res);
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,co=0;
    double he=0;
    while(cin>>n){
        he=sqrt(n);
        int ser[n+1];
        for(int i=2;i<=n;i++)ser[i]=1;
        for(int i=2;i<=he;i++)if(ser[i]==1)for(int j=2;j*i<=n;j++)ser[i*j]=0;
        for(int i=2;i<=n;i++)if(ser[i]==1)co++;
        cout<<co<<endl;
        co=0;
    }
}

C++: /*Filename: aoj0009.cpp
 *Author: Mushiyo
 */

#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

const int size = 999999 + 1;
bool isPrime[size];
vector<int> prime;

void sieveOfEratosthenes() {
	for (int i = 2; i < size; ++i) {
		isPrime[i] = true;
	}

	int sqrtSize = sqrt(size) + 1;

	for (int i = 2; i < sqrtSize; ++i) {
		if (isPrime[i] == true) {
			for (int j = i * i; j < size; j += i) {
				isPrime[j] = false;
			}
		}
	}

	for (int i = 2; i < size; ++i) {
		if (isPrime[i]) {
			prime.push_back(i);
		}
	}
}

int main() {
	sieveOfEratosthenes();

	int n = 0;

	while (cin >> n) {
		int countPrime = 0;

		for(int i = 0; i < prime.size(); ++i){
			if(prime[i] > n){
				break;
			}
			else{
				++countPrime;
			}
		}

		cout << countPrime << endl;
	}

	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
int pri[1000000];
int main()
{
    int i,j;
    memset(pri,0,1000000*sizeof(int));
    for (i=2;i<=1000;i++)
    {
        for (j=i*i;j<1000000;j=j+i)
        {
            pri[j]=1;
        }
    }
    int n;
    while (scanf("%d",&n)!=EOF)
    {
        int sum=0;
        for (i=2;i<=n;i++)
            if (pri[i]==0) sum++;
        printf("%d\n",sum);
    }
    return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

vector<bool> eratosthenes_sieve(size_t size) {
  vector<bool> is_prime(size + 1, true);
  for (size_t i = 0; i <= size; i++) {
    if (i < 2) {
      is_prime[i] = false;
    } else if (is_prime[i]) {
      for (size_t j = 2 * i; j <= size; j += i) {
        is_prime[j] = false;
      }
    }
  }
  return is_prime;
}

int main() {
  int n = 1'000'000 - 1;
  auto sieve = eratosthenes_sieve(n);
  vector<int> acc(n + 1, 0);
  rep(i, n) { acc[i + 1] = acc[i] + (sieve[i + 1] ? 1 : 0); }

  int m;
  while (cin >> m) {
    cout << acc[m] << "\n";
  }
  return 0;
}

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

int Prime[NUM];

int main(){

	for( int i=0;i<NUM;i++ ){
		Prime[i]=1;
	}
	Prime[0]=Prime[1]=0;
	for( int i=2;i<NUM;i++ ){
		if( Prime[i] ){
			for( int j=i*2;j<NUM;j+=i ){
				Prime[j]=0;
			}
		}
	}
	int n;
	while( cin>>n ){
		int primenum=0;
		for( int i=0;i<=n;i++ ){
			primenum+=Prime[i];
		}
		cout<<primenum<<endl;
	}

	return 0;
}

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

using namespace std;


vector<int> era(int n){
	vector<int> prime;
	bool *is_prime = new bool[n+1];
	fill(is_prime,is_prime+n+1,true);
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i <= n; i++){
		if(is_prime[i]){
			prime.push_back(i);
			for(int j = i*2; j <= n; j+=i){
				is_prime[j] = false;
			}
		}
	}
	delete []is_prime;
	return prime;
}

int main(){

	int n;
	while(1){
		if(cin.eof())
			break;
		cin >> n;
		vector<int> p = era(n);
		cout << p.size() << endl;
	}

	return 0;
}

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

int count(int n);

int main(void){
	while (true){
		int n; cin >> n;
		if (!n){
			break;
		}
		cout << count(n) << endl;
	}
	return 0;
}

int count(int n){
	int ct = 0;
	bool *prime = new bool[n];
	//bool prime[999999];
	for (int i = 0; i <= n;i++){
		prime[i] = 0;
	}
	prime[2] = 1;
	for (int i = 3; i <= n; i = i + 2){
		prime[i] = 1;
	}
	for (int i = 3; i <= n; i = i + 2){
		if (prime[i] == 0) continue;
		for (int j = i * 2; j <= n; j = j + i){
			prime[j] = 0;
		}
	}
	for (int i = 3; i <= n; i = i + 2){
		if (prime[i] == 1) ct++;
	}
	ct++; //2を数えていない分
	return ct;
	delete[] prime;
}