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++: while True:
	try:
		n=int(input())
		a=[True]*(n+1)
		a[0]=a[1]=False
		for i in range(2,int(n**0.5)+1):
			if a[i]:
				for j in range(i**2,n+1,i):
					a[j]=False
		print(a.count(True))
	except:
		break

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

using namespace std;

int MAX = 9;

vector <int> v;

int main() {
	int n;
	
	while (cin>>n) {
		v.clear();
		
		for (int i=0; i<=MAX; i++) v.push_back(n-i);
		sort(v.begin(), v.end());
		
		int ans = 0;
		
		for (int i=0; i<=MAX; i++) {
			for (int j=0; j<=MAX; j++) {
				for (int k=0; k<=MAX; k++) {
					if (binary_search(v.begin(), v.end(), i+j+k)) ans++;
				}
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	int n;
	int count = 1;
	if (n == 1) {
		cout << 0 << endl;
	}
	else if (n == 2) {
		cout << 1 << endl;
	}
	else {
		for (int t = 3; t <= n - 1; t += 2) {
			FOR(i, 1, t - 1) {
				if (t%i == 0) {
					break;
				}
				if (i == t - 1) {
					count++;
					break;
				}
			}
		}
		cout << count << endl;
	}
	
	return 0;
}

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

bool isPrime(int x) {
  if(x == 2) {
	return true;
  }
  else if(x < 2 || x % 2 == 0) {
	return false;
  }
  else {
	for(int i = 3; i <= (int)sqrt(x); i += 2) {
	  if(x % i == 0) {
		return false;
	  }
	}
  }
  return true;
}

int main() {
  int n;
  bool a[1000000];

  for(int i = 1; i < 1000000; ++i) {
	if(isPrime(i)) {
	  a[i] = true;
	}
  }
  
  while(cin >> n) {
	cout << accumulate(&a[1], &a[n+1], 0) << endl;
  }
  return 0;
}

/*-- primitive algorithm --*/
/*
bool isPrime(int n) {
  for(int i = 2; i < n; ++i) {
	if(n % i == 0) return false;
  }
  return true;
}
*/

C++: #include<iostream>
#include<stdio.h>
using namespace std;
typedef long long ll;
const ll MAX=1e6;
ll prime[MAX+2],mark[MAX+2],ans[MAX+2];
void Prime(){
    memset(mark,0,sizeof(mark));
    ll index=0;
    for(ll i=2;i<=MAX;i++){
        if(mark[i]) continue;
        else{
            prime[++index]=i;
            for(ll j=i*i;j<=MAX;j+=i){
                mark[j]=1;
            }
        }
    }
}
int main(){
    ll a;
    memset(ans,0,sizeof(ans));
    Prime();
    for(int i=2;i<=MAX-2;i++){
        if(mark[i]==0) ans[i]=ans[i-1]+1;
        else ans[i]=ans[i-1];
    }
    while(scanf("%I64d",&a)!=EOF){
        cout<<ans[a]<<endl;;
    }
    return 0;
}

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

int main(){
    bool is_prime[1000000];

    is_prime[0] = is_prime[1] = false; 
    for(int i=2; i<1000000; i++){
        is_prime[i] = true;
    }
    for(int i=2; i*i<1000000; i++){
        if(is_prime[i]){
            for(int j=i*i; j<1000000; j+=i){ 
                is_prime[j] = false; 
            }
        }
    }
    int n_prime[1000000];
    int cnt = 0; 
    for(int i=0; i<1000000; i++){
        if(is_prime[i])
        cnt++;
        n_prime[i] = cnt;
    }
    while(true){
        int n;
        cin >> n;
        if(cin.eof())
        break;
        cout << n_prime[n] << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include <cstring>
using namespace std; 
int main()
{
	    int n;
//		for(int i=2;i<=1000;++i)
//		{
//			for(int j=2;j*i<=1000000;++j)
//			{
//				a[i*j]=1;
//			}
//	}
//for(int i=2;i*i<=n;i++)
//		{
//			if(a[i]==false)
//				for(int j=i*2;j<=n;j+=i)
//					a[j]=true;
//		}
	while(cin>>n)
	{ 
	    bool a[1000001]; 
	   // memset(a,0,sizeof(a));
		int count=0;
		for(int i=2;i*i<=n;i++)
		{
			if(a[i]==false)
				for(int j=i*2;j<=n;j+=i)
					a[j]=true;
		}
		for(int k=2;k<=n;k++)
		{
			if(!a[k])
			count++;
		}
		cout<<count<<endl;
	
	
		
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>

int main(void) {
  int n, *ar, *sum, i, j;
  ar = (int*)malloc(sizeof(int) * 1000000);
  sum = (int*)malloc(sizeof(int) * 1000000);
  for(i = 1; i < 1000000; ++i) ar[i] = 0, sum[i] = 0;
  for(i = 2; i < 1000; ++i) {
    if(!ar[i]) for(j = 2; i * j < 1000000; ++j) ar[i] = 1;
  }
  for(i = 2; i < 1000000; ++i) sum[i] = sum[i - 1] + ar[i];
  while(scanf("%d", &n) != EOF) {
    printf("%d\n", ar[n]);
  }
  free(ar);
  free(sum);
  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){
		cin >> n;
		if(cin.eof())
			break;
		vector<int> p = era(n);
		cout << p.size() << endl;
	}

	return 0;
}

C++: #include <iostream>

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

using namespace std;

static const int LIM = 1000000;
bool np[LIM / 2];

bool is_prime(int n)
{
	return n == 2 || (n % 2 == 1 && !np[n/2]);
}

int main()
{
	np[0] = true;
	for (int i = 3; i * i < LIM; i += 2)
		if (!np[i/2])
			for (int j = 3 * i; j < LIM; j += 2 * i) np[j/2] = true;

	int N;
	while (cin>>N)
	{
		int c = 0;
		rep(i,N+1)
			if (is_prime(i)) c++;
		cout << c << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main(){
	int i,j,n;
	static bool prime[1000001];
	for (i = 3; i <= 1000000; i += 2){
		prime[i] = true;
	}
	prime[2] = true;

	for (i = 3; i <= 1000; i += 2){
		if (prime[i] == 1){
			for (j = 3; j <= 1000000 / i; j += 2){
				prime[i * j] = false;
			}
		}
	}
	while(cin >> n && n){
		int count = 0;
		for(i=2;i<=n;i++){
			if(prime[i] == true) count++;
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<math.h>
bool b(int n){
if (n < 2)  
        return false;  
    //偶数一定不是素数，去掉偶数  
    if (n == 2)  
        return true;   
    //从3?始,判断指定数的平方根内的数  
    for (int i = 3; i <= sqrt(n); i++) {  
        if (n % i == 0)  
            return false;  
    }  
    return true; 
}
int main(){
int n,c,i;
while(std::cin>>n){
c=0;
if(n==2)c=1;
for(i=3;i<=n;i+=2){
if(b(i))c++;
}
std::cout<<c<<"\n";
}

return 0;
}

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

int main(){
  bool is_prime[1000000];
  for(int i=0;i<1000000;i++){
    is_prime[i] = true;
  }
  is_prime[0] = false;
  is_prime[1] = false;
  
  for(int i=2;i<1000000;i++){
    if(is_prime[i]){
      for(int j=2*i;j<1000000;j += i){
	is_prime[j] = false;
      }
    }
  }
 
 int n,counter;
 cin >> n;
 counter = 0;
 
 for (int k = 1; k <= n; k++)
   if(is_prime[k]){
     counter++;
   }

 cout << counter << endl;
 
 return 0;
}