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 <cstdio>
#include <cstdlib>
#include <iostream>
#include <math.h>

using namespace std; 

int list[1000000]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163,
 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251,
 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443,
 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557,
 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647,
 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757,
 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983,
 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069};

long int a,b,loop,hasil,input,mid;
long int lo;
long int hi;

 bool Prima(unsigned long n) 
{
    for (unsigned short i = 0; list[i]*list[i] <= n; i++) 
	{
        if (n % list[i] == 0) 
		{
            return false;
        }
    }
 
    return true;
}

int main()
{
	lo=1087;
	a=180;
	while(lo<=100003)
	{
		if(Prima(lo))
		{
			list[a]=lo;
			a++;
		}
		lo+=2;
	}
	//printf("%d",list[78498]);
	while(scanf("%ld",&input)!= EOF)
	{	
	lo=0;
	hi=78497;
	/*while(lo<=hi)
        {
            mid=(lo+hi)/2;
            if (list[mid]<input)
            {
                lo=mid+1; 
            } 
            else if(list[mid]>input)
            {
                hi=mid-1; 
            }
            else 
            {
                break; 
            } 
        }*/
	while(input>=list[lo])
	{
		lo++;
	}
	printf("%d\n",lo);
	}
	return 0; 
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM 1000000
using namespace std;

int num[MAXNUM]={0};

int main(){
  int n;
  vector<int> vec;
  vec.push_back(2);
  while(cin >> n){
    for(int i = 3; i<=n; i+=2){
      if(num[i]==1) continue;
      FOR(j, 1, MAXNUM){
        if(i*j>=n)  break;
        num[i*j]=1;
      }
      vec.push_back(i);
    }
    for(int i=0; i<=vec.size(); i++){
      if(vec[i]>n || i==vec.size()){
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

bool p[1000000];

void prime() {
  fill(p, p+1000000, true);
  p[0] = p[1] = false;
  
  FOR(i, 2, 1000000) {
    if(!p[i])continue;
    for(int j = 2; i*j < 1000000; j++) {
      p[i*j] = false;
    }
  }
}    


int main() {
  int n, count;

  prime();
  while(cin >> n) {
    count = 0;
    for(int i = 2; i <= n; i++) {
      if(p[i] == true)count++;
    }
    cout << count << endl;
  }
}

C++: #include<stdio.h>
int prime[1000000];
int main() {
	prime[0] = -1;
	prime[1] = -1;
	for (int i = 2; i<1000000; i++) {
		if (prime[i] == 0) {
			prime[i] = 1;
			for (int j = i * 2; j<1000000; j += i)prime[j] = -1;
		}
	}
	int now;
	while (~scanf("%d", &now)) {
		int ans = 0;
		for (int i = 1; i<now + 1; i++)if (prime[i] == 1)ans++;
		printf("%d\n", ans);
	}
}

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

int main(){
	int NUM;
	while(std::cin >> NUM){
		std::list<int> numList,primeList;
		if(NUM<2){
			return 0;
		}
		for(int i=2;i<=NUM;++i){
			numList.push_back(i);
		}
	
		for(int i=numList.front();i<std::sqrt(NUM);i=numList.front()){
			primeList.push_back(i);
			numList.erase(std::remove_if(numList.begin(),numList.end(),[&](int num){return num%i==0;}),numList.end());
		}
		std::copy(numList.begin(),numList.end(),std::back_inserter(primeList));

		std::cout << primeList.size() << std::endl;
		}
	return 0;
}

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

#define N 1000000

using namespace std;

int main()
{
  bool primes[N];

  fill(primes+2, primes+N, true);

  // eratos
  for(int i = 2; i < N; ++i)
    if(primes[i])
      for(int j = i+i; j < N; j += i)
	primes[j] = false;

  int n, count;
  while(cin>>n){
    count = 0;
    for(int i = 2; i <= n; ++i)
      if(primes[i]) ++count;

    cout << count << endl;
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >> n){
    n++;
    int ans=0;
    int math[n];
    for(int i=0;i<n;i++){
      math[i]=0;
    }
    n--;
    math[1]=1;
    for(int i=2;i<n+1;i++){
      int bell=i;
      if(math[i]==0){
	ans++;
	math[i]=1;
      }
      while(bell<=n){
	bell+=i;
	if(math[bell]==0){
	  math[bell]=1;
	}
      } 
    }
    cout << ans << endl;
  }
}

C++: #include <iostream>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)

int main(){
	int n;
	while(cin >> n){
		bool bin[1000000] = {};
		int m = 0;
		FOR(i,2,n+1)if(!bin[i]){
			REP(j,n/i+1)bin[i*j] = true;
			m++;
		}
		cout << m << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
	vector<long long int>D(1000001 , 1);
	D[0] = 0;
	D[1] = 0;
	for(long long int i = 2; i <= sqrtl(1000001); i++)
	{
		if(D[i])
		{
			long long int j = 2;
			while(i*j < 1000001)
			{
				D[i*j] = 0;
				j++;
			}
		}
	}
	for(long long int i = 1; i < 1000001; i++)
	{
		D[i] += D[i - 1];
	}
	long long int n;
	while(cin >> n)cout << D[n] << endl;
	return 0;
}