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 <stdio.h>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;

int sosuu(int n);

int main(){
    int n=0;
    int num=0;
    int a[30][2]={0};
    int max=0;
    while(scanf("%d",&n)!=EOF){
        if(max<n){
            max=n;
        }
        a[num][0]=n;
        num++;
    }
    
    int b[max];
    int c[max];
    int so=0;
    for(int i=0; i<=max; i++){
        b[i]=i;
    }
    b[1]=0;
    
    for(int i=2; i<sqrt(max); i++){
        for(int j=i+1; j<=max; j++){
            if(j%i==0){
                b[j]=0;
            }
        }
    }
    
    for(int i=0; i<=max; i++){
        if(b[i]!=0){
            c[so]=i;
            so++;
        }
    }
    
    
//    for(int j=0; j<num; j++){
//        cout<<a[j][0]<<"\n";
//    }
//    
//    for(int j=0; j<=so; j++){
//        cout<<c[j]<<"\n";
//    }
    
    
    
    
    for(int i=0; i<num; i++){
        for(int j=0; j<so; j++){
            if(c[j]<=a[i][0]){
                a[i][1]++;
            }else{
                j=so;
            }
        }
    }

    
    for(int j=0; j<num; j++){
        cout<<a[j][1]<<"\n";
    }
    
}

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

int main(){
    int ans,n;
	while(1){
		ans=0;
		if(scanf("%d",&n)==EOF)break;
		if(n==1){
			cout<<0<<endl;
		}else{
			if(n>=2)ans++;
			if(n>=3)ans++;
			if(n>=5)ans++;
			if(n>=7)ans++;
			if(n>=9){
				for(int i=9;i<=n;i+=2){
			        int prime=1;
				    for(int k=3;k<=sqrt(i);k+=2){
					    if(i%k==0){
						    prime=0;
						    break;
    					}
					}
				    if(prime)ans++;
				}
			}
		cout<<ans<<endl;
		}
	}
}

C++: /*************************************************************************
	> File Name: aoj0009.cpp
	> Author: BMan
	> Mail: luo-kai-jia@163.com
	> Created Time: Wed 24 Oct 2018 08:50:17 PM CST
 ************************************************************************/

#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <limits.h>
#include <queue>
#include <math.h>
#include <iostream>

#define FOR(i, x, y) for (int i = x; i <= y; i++)
#define REPEAT(_N) for (int _i = 0; _i < _N; _i++)

using namespace std;

inline bool Read(int &a) { return scanf("%d", &a) != EOF; }

const int maxn = 1 << 20;
int p[maxn];
int Process() {
    p[0] = p[1] = 0;
    for (int i = 2; i < maxn; i++) p[i] = 1;
    for (int i = 2; i < maxn; i++) {
        if (!p[i]) continue;
        for (int j = i + i; j < maxn; j += i) {
            p[j] = 0;
        }
    }
    for (int i = 2; i < maxn; i++) {
        p[i] += p[i - 1];
    }
    int n;
    while (Read(n)) {
        printf("%d\n", p[n]);
    }
    return 0;
}

int main() {
    std::ios::sync_with_stdio(false);
    return Process();
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int pri[1000000];
int sz;

void get_pri()
{
    sz=0;
    for(int i=2;i<=999999;i++)
    {
        int ok=0;
        for(int j=2;j*j<=i;j++)
            if(i%j==0){
                ok=1;
                break;
            }
        if(ok==0)
            pri[sz++]=i;
    }
}

int main()
{
    int n;
    get_pri();
    while(scanf("%d",&n)!=EOF)
    {
        int pos=lower_bound(pri,pri+sz,n)-pri;
        if(pri[pos]==n)
            printf("%d\n",pos+1);
        else
            printf("%d\n",pos);
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,n[99999],j,o=0;
	for(int i=2;i<=99999;i++){
		for( j=2;j<i;j++){
			 if(i%j==0)break;
		}
		if(i == j)n[i]=1;
		else n[i]=0;
	}	
	cin>>a;
	for(int k=2;k<=a;k++) if(n[k]) o++;
	cout<<o<<endl;
}

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

vector<int> sieve;

void make_prime(int n){
  bool a[1000000];
  for(int i = 0; i < 1e6; i++)a[i] = false;
  a[0] = true;
  a[1] = true;
  for(int i = 2; i <= n; i++){
    if(a[i])continue;
    sieve.push_back(i);
    for(int j = i; j <= n; j += i){
      a[j] = true;
    }
  }
}
int main(){
  int n;
  cin >> n;
  make_prime(n);
  cout << sieve.size() << endl;
}

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

bool sieve[1000000];
void makesieve();

int main()
{
	makesieve();
	while(1)
	{
		int n,ans=0;
		std::cin>>n;
		if(std::cin.eof())break;
		for(int i=0;i<=n;i++)
		{
			ans+=sieve[i]?1:0;
		}
		std::cout<<ans<<std::endl;
	}
	return 0;
}

void makesieve()
{
	memset(sieve,-1,sizeof(sieve));
	sieve[0]=false;sieve[1]=false;
	for(int i=2;i<1000000;i++)
	{
		for(int j=i*2;j<1000000;j+=i)
		{
			sieve[j]=false;
		}
	}
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

#define REP(i,s,e) for(int i=int(s);i<int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

using namespace std;

int a[1000000];

bool p(int n){
int m;
for(int i=2;i<=n;i++){
if(n%i==0){ m=i; break;
	}
}
if(m==n) return true;
else return false;
}

int main(){

int n;
while(1){

cin >> n;

if(cin.fail()) break;

int f=floor(sqrt(1.0*n));
int c=floor(sqrt(1.0*n)+1);

for(int j=c;j<=n;j++) a[j]=j;


int x=0;
for(int i=2;i<=f;i++){

	if(p(i)){
	x++;
	for(int j=c;j<=n;j++){
	if(a[j]%i==0 && a[j]!=0) a[j]=0;
	}
	}

}
int y=0;
for(int i=c;i<=n;i++){
	if(a[i]!=0) y++;
}

	cout << x+y << endl;

}

	return 0;
}

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

int eratos(int n) {
	int cnt = 0;
	vector<bool> is_prime(n+1,true);
	is_prime[0] = is_prime[1] = false;
	for (auto i = 2; i <= n; i++) {
		if (is_prime[i]) {
			++cnt;
			for (auto j = 2*i; j <= n; j += i)
				is_prime[j] = false;
		}
	}
	return cnt;
}

int main() {
	for (int n; cin>>n; cout<<eratos(n)<<endl);
	return 0;
}

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

int main(){
	int NUM;
	while(std::cin >> NUM){
		std::list<int> numList,primeList;
		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));
		int cnt=numList.size()+primeList.size();	
		std::cout << cnt << std::endl;

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

C++: #include<iostream>
#include<string.h>
int main(){bool*v=new bool[1000000];for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{memset(v,1,c=(n&1?n:--n)/2+1);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];}printf("%d\n",e);}delete[]v;}

C++: #include <iostream>
#include <string>
#include <array>

using namespace std;

int main(void){
  const int n = 1000000;
  bool* check_A = (bool*)malloc(sizeof(bool)*n);
  int*  num_A   = (int*)malloc(sizeof(int)*n);
  int N = 0, temp = 2;
  memset(check_A, true, n);
  check_A[0] = false;
  check_A[1] = false;
  num_A[0] = 0;
  num_A[1] = 0;
  for(int i = 0; i < n; i++){
    if(check_A[i]){
      for(;temp < i;temp++){
	num_A[temp] = N;
      }
      temp++;
      num_A[i] = ++N;
      for(int j = 2; i*j < n; j++){
	check_A[i*j] = false;
      }
    }
  }
  int s;
  while(cin >> s){
    cout << num_A[s] << endl;
  }
  return 0;
}