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>

using namespace std;

int main()
{
	int i, j, n;
	int count = 0;

	while (cin >> n) {
		for (i = 2; i <= n; i++) {
			for (j = 2; j < i; j++) {
				if (i % j == 0) {
					break;
				}
			}
			if (i == j) {
				count++;
			}
		}
		cout << count << endl;
		count = 0;
	}

	return 0;
}

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

int main(void) {
  int table[MAX_NUM + 1] = {0};
  for(int i = 2; i < MAX_NUM; i++) {
    for(int j = i * 2; j < MAX_NUM; j = j + i) {
      table[j] = 1;
    }
  }

  int num;
  int ans = 0;
  while(cin >> num) {
    for(int i = 2; i <= num; i++) {
      if(table[i] == 0) {
        ans++;
      }
    }
    cout << ans << endl;
    ans = 0;
  }

  return 0;
}

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

int main(){

	int n, i, j, prmnum;
	bool prm = true;
	while(cin>>n){
		prmnum = 0;
		for( i=2;i<=n;i++ ){
			prm = true;
			for( j=2;j<i;j++ ){
				if( i%j == 0 ){
					prm = false;
					break;
				}
			}
			if(prm)prmnum++;
		}
		cout << prmnum << endl;
	}
	return 0;
}

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

int main(){
    vector<int> prime;
    int n;
    for(int i=2;i<1000000;i++){
        bool isprime=true;
        for(int j=2;j<=sqrt(i);j++){
            if(i%j==0){
                isprime=false;
                break;
            }
        }
        if(isprime) prime.push_back(i);
    }
    while(cin >> n){
        for(int i=0;i<prime.size();i++){
            if(prime[i]>n){
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

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

int main(){
  int MAX = 1000000;
  int n;
  int cnt=0;
  vector<bool> num(n);
  
  for(int i=0; i<MAX; i++){
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;

  for(int i=2; i*i<=MAX; i++){
    if(num[i]){
      for(int j=i*2; j<MAX; j+=i){
	num[j] = false;
      }
    }
  }

  while(cin >> n){
    cnt = 0;
    for(int i=0; i<n; i++){
      if(num[i]) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = 998244353;
const double EPS = 1e-9;

bool s[1000000] = {};
int sosu[1000000] = {};
void erast(){
  memset(s,1,sizeof(s));
  s[1] = false;
  s[0] = false;
  REP(i,2,1000){
    if(s[i]){
      REP(j,2,1000000){
        if(i*j>=1000000) break;
        s[i*j] = false;
      }
    }
  }
  REP(i,2,1000000) sosu[i] = sosu[i-1]+s[i];
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    erast();
    int n;
    while(cin >> n){
      cout << sosu[n] << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    int MAX = 1000000;
    int lim = sqrt(MAX);
    vector<int> is_prime(MAX, 1);
    is_prime[0] = is_prime[1] = 0;
    for(int i = 2; i < MAX; ++i) {
        if(is_prime[i])
            if(i < lim) 
                for(int j = i*i; j < MAX; j += i) is_prime[j] = 0;
    }

    vector<int> primes;
    for(int i = 0; i < MAX; ++i)
        if(is_prime[i]) primes.push_back(i);

    int n;
    while(cin >> n) 
        cout << upper_bound(primes.begin(), primes.end(), n)-primes.begin() << endl;
    return 0;
}

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

const int MX = 1000000;
bool prime[MX];
int cnt[MX];

int main() {
    for (int i=0; i<MX; ++i) prime[i] = true;
    prime[0] = prime[1] = false;
    for (int i=2; i<MX; ++i) {
        if ( ! prime[i]) continue;
        for (int j=i; (long long)i*j<MX; ++j) {
            prime[i*j] = false;
        }
    }
    cnt[0] = 0;
    for (int i=1; i<MX; ++i) {
        cnt[i] = cnt[i-1] + prime[i];
    }
    int N;
    while (cin >> N) {
        cout << cnt[N] << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
  int n;
  
  while(1) {
    cin >> n;
    if(cin.eof()) {
      break;
    }
    int m = (int)sqrt(n);
    
    vector<bool> h(n+1, true);
    h[0] = false;
    h[1] = false;
    
    for(int i = 2; i <= m; i++) {
      if(h.at(i)) {
	for(int s = 2; s*i < h.size(); s++) {
	  if(h.at(s*i))
	    h[s*i] = false;
	}
      }
    }
    
    int ans=0;
    for(auto f : h) {
      if(f)
	ans++;
    }
    cout << ans << endl;
  }
  
  return 0;
}

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

using namespace std;

int solist[999999];

int main(int argc, char* argv[])
{
	int num;
	int count;
	int i, j;
	int val;

	count = 8;
	solist[0] = 2;
	solist[1] = 3;
	solist[2] = 5;
	solist[3] = 7;
	solist[4] = 11;
	solist[5] = 13;
	solist[6] = 17;
	solist[7] = 19;

	for (num = 3; num < 1000000; num += 2) {
		for (i = 0; i < count; i++) {
			if (num % solist[i] == 0) break;
		}
		if (i == count) solist[count++] = num;
	}

	while (cin >> val) {
		for (i = 0; i < count; i++) {
			if (solist[i] > val) {
				cout << i + 1 << endl;
				break;
			}
		}
		if (i == count) cout << count << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
const int MAX_N = 1000000; // いくつまで調べるか
bool prime[MAX_N + 1]; // 添字が素数ならtrue、それ以外はfalse
void sieve()
{
  prime[0] = prime[1] = false; // 例外処理
  // 配列prime の初期化
  for(int i = 2; i <= MAX_N; ++i)
    prime[i] = true;
  // 素数でないものを調べる
  for(int i = 2; i <= MAX_N; ++i)
    if(prime[i])
      for(int j = i * 2; j <= MAX_N; j += i)
	prime[j] = false;
	}

int is_prime(int n)
{
  return prime[n];
  }

/*bool is_prime(int n)
{
  if(n == 1)return false;
  for(int i = 2; i < n; ++i)
    if(n % i == 0)return false;
  return true;
  }
*/
int main()
{
  sieve();
  int a;
  while(cin >> a){
    //cin >> a;
    //if(a==EOF)return 0;
    int count=0;
    //int tmp;
    for(int i=1;i<=a;i++){
      if(is_prime(i))count++;
    }
    printf("%d\n",count);
  }
}

C++: #include<iostream>
using namespace std;
#define L long long int
int main(){
int n,ans,i,j;
while(cin>>n){
	ans=0;
	for(i=2;i<=n;i++){//search for 2 to n
		for(j=2;j<=i;j++)if(i%j==0)break;
		if(j==i)ans++;
	}
	cout<<ans<<endl;
}
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()
using namespace std;

int main(){
  int n;
  while(cin >> n){
    int ans=0;
    vector<int> vec;
    vec.push_back(2);
    for(int i = 3; i<=n; i+=2){
      bool isPrimeN = true;
      for(int j=3; j<=floor(sqrt(i)); j++){
        if(i%j==0){
          isPrimeN = false;
          break;
        }
      }
      if(isPrimeN){
        vec.push_back(i);
      }
    }
    cout << vec.size() << endl;;
  }
  return 0;
}