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

using namespace std;

////Nayeem Shahriar Joy,Applied Physics &Electronic Engineering,University of Rajshahi.

int main()

{
    bool prime[1000001];
    memset(prime,true,sizeof(prime));
    for( int i=4;i<=999999;i=i+2)
    {
        prime[i]=false;
    }
    for(int i=3;i*i<=999999;i++)
    {
        if(prime[i]==true){
        for(int j=i*2;j<=999999;j=j+i)
        {
            prime[j]=false;
        }
        }
    }
    int n;

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

C++: #include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	int a = 0;
	for(int i=2;i<=n;i++){
		bool x = true;
		for(int j=2;j<i;j++){
			if(i%j==0){
				x = false;
				break;
			}
		}
		if(x)
			a++;
	}
	cout << a << endl;
	return 0;
}

C++: #include <iostream>
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 <= sqrt(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;
}

C++: //#define _USE_MATH_DEFINES
#include <iostream>
//#include <stdio.h>
//#include <iomanip>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <cmath>

using namespace std;

#define N_MAX 1000000

int kouho[N_MAX / 2];

int main(){

	vector <int> sosuu;
	int check;
	//int kouho[N_MAX / 2];
	int n;
	int cnt;

	for (int i = 0; i < N_MAX / 2; i++){
		kouho[i] = i * 2 + 1;
	}
	kouho[0] = 0;

	sosuu.push_back(2);
	check = 3;

	while (check < 1000){
		sosuu.push_back(check);
		for (int i = check/2; i < N_MAX / 2; i++){
			if ((kouho[i] % check) == 0){
				kouho[i] = 0;
			}
		}
		for (int i = check/2; i < N_MAX / 2; i++){
			if (kouho[i] != 0){
				check = kouho[i];
				break;
			}
		}
	}
	
	
	while (cin >> n){
		cnt = 0;
		if (n <= 1000){
			for (int i = 0; i < sosuu.size(); i++){
				if (sosuu[i] <= n)cnt++;
				else break;
			}
		}
		else{
			cnt += sosuu.size();
			for (int i = 0; i < N_MAX /2; i++){
				if (kouho[i] > n){
					break;
				}
				else{
					if (kouho[i] != 0)cnt++;
				}
			}
		}
		cout << cnt << endl;
	}

	

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

bool is_SPRP(uint32_t n, uint32_t a) {
  uint32_t d = n - 1, s = 0;
  while ((d & 1) == 0) {
    ++s;
    d >>= 1;
  }
  uint64_t cur = 1, pw = d;
  while (pw) {
    if (pw & 1) {
      cur = (cur * a) % n;
    }
    a = ((uint64_t)a * a) % n;
    pw >>= 1;
  }
  if (cur == 1) {
    return true;
  }
  for (uint32_t r = 0; r < s; r++) {
    if (cur == n - 1) {
      return true;
    }
    cur = (cur * cur) % n;
  }
  return false;
}

bool is_prime(uint32_t x) {
  if (x <= 1) return false;
  if (x < 1ULL << 32) {
    uint32_t bases[] = {2, 7, 61};
    for (uint32_t i = 0; i < sizeof(bases) / sizeof(bases[0]); ++i) {
      if (x != bases[i] && !is_SPRP(x, bases[i])) {
        return false;
      }
    }
    return true;
  }
}

int p[1000000];

int main() {
  int n;
  for (int i = 0; i < 1000000; ++i) {
    p[i] = is_prime(i);
  }
  for (int i = 1; i < 1000000; ++i) {
    p[i] += p[i - 1];
  }
  while (cin >> n) {
    cout << p[n] << endl;
  }
}

C++: #include <iostream>

bool IsPrime(int n) {
    for(int i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
	// your code goes here

	int n;
	while(1){
		cin >> n;
		if(cin.eof()){
			break;
		}
		int count = 0;
		for(int i=2;i<=n;i++){
			if(IsPrime(i)){
				count++;
			}
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	bool isprime[1000000];
  rep(i, 1000000) isprime[i] = true;
  isprime[0] = isprime[1] = false;
  FOR(i, 2, sqrt(1000000)) {
    if(isprime[i]) {
      ll j = i + i;
      while(j <= 1000000) {
        isprime[j] = false;
        j += i;
      }
    }
  }
  ll n;
  while(cin >> n) {
    ll cnt = 0;
    rep(i, n + 1) if(isprime[i]) cnt++;
    cout << cnt << endl;
  }
	return 0;
}

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


bool isPrime(int I)
{
	int b = sqrt (I*1.0) + 1;
	for(int i = 2; i < b; i ++){
		if(I % i == 0)
			return false;
	}
	return true;
}


int main(){
	int n;
	while(cin>>n){
		int total = 0;
		for(int i = 2; i <= n; i ++)
		{		
			if(isPrime(i) == true){
				total ++;
			}
		}
			cout<<total<<endl;
		}
	
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 0x3f3f3f3f
#define inff -30000000
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
const int MAX=1000000+10;
int prime[MAX];
bool notprime[MAX];
int num=0;
void init(){
    memset(notprime,0,sizeof(notprime));
    for(int i=2;i*i<=MAX;i++){
        if(!notprime[i]){
            prime[num++]=i;
            for(int j=i*i;j<=MAX;j+=i)
                notprime[j]=1;
        }
    }
}
int main(){
    #ifdef SIYU
    freopen("in.txt","r",stdin);
    #endif // SIYU
    int n;
    init();
    while(cin>>n){
        //int *p=upper_bound(prime,prime+num,n);
        //int ans=p-prime;
        //cout<<ans<<endl;
        int ans=0;
        for(int i=0;i<num;i++){
            if(prime[i]<=n)
                ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}