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 := i - 1; j >= 1; j-- {
				if i%j == 0 && j != 1 {
					flag = true
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
	long long int n;
	while (cin >> n) {
		int m = 0;
		long long int prime[2000000];
		bool is_prime[2000000];
		for (int i = 0; i <= n; i++) {
			is_prime[i] = true;
		}
		is_prime[0] = is_prime[1] = false;
		for (int i = 2; i <= n; i++) {
			if (is_prime[i]) {
				m++;
				for (int j = i * 2; j <= n; j += i) {
					is_prime[j] = false;
				}
			}
		}
		cout << m << endl;
	}
	return 0;
}

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

int main(void)
{
    long num, length, prime[1000];

    while(cin >> num)
    {
        length = 0;
        int count = 0;
        for (int n = 2; n <= num; n++)
        {
            bool isPrime = true;
            for(int i=0; i < length-1; i++)
            {
                if (!(n % prime[i]))
                {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime)
            {
                prime[length] = n;
                length++;
            }
        }
        cout << length << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
        int prime[40];
        bool is_prime[40];
        int i=2,j=2,n,count=0;
        while(scanf("%d",&n) != EOF){
                int p = 0;
                for(i = 0;i <= n; i++){
                        is_prime[i] = true;
                }
                is_prime[0]=is_prime[1]=false;
                for(i = 2; i<=n;i++){
                        if(is_prime[i]){
                                prime[p++] = i;
                                for(j = 2*i; j <= n; j+=i) is_prime[j] = false;
                        }
                }
                cout << p << endl;
        }
        return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
#define MAX 100

bool prime[MAX]={};

void run(){
  for(int i=2;i<MAX;i++){
    prime[i]=true;
  } 

  for(int i=2;i<MAX;i++){
    if(!prime[i])continue;
    for(int j=2;j*i<MAX;j++){//i*1 is prime number
      prime[i*j]=false;
    }
  }
  return;
}

int main(){

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

}

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

#define LIM 1000000
using namespace std;

void prime();

vector<int> prime_map;

int main(){
  int num, i=0,j=0;
  vector<int> count;
  prime();
  cout<<"plese"<<endl;
  while(cin){
    cin>>num;
    i=0;
    while(prime_map[i]<=num){
      i=i+1;
    }
    count.push_back(i);
    j++;
  }

  i=0;
  while(i<j){
    cout<< count[i]<<endl;
    i++;
  }
}

void prime(){
  bool judge;
  for(int i = 2; i <= LIM;i++){
    judge=1;
    for(int j= 2; j < i/2; j++){
      if(i%j == 0)judge = 0 break;
    }
    if(judge == 1)prime_map.push_back(i);
  }
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,o=0;
	bool n[1000000];
	for(int i=2;i<=999999;i++){
		n[i]=true;
	}
	n[0]=n[1]=false;
		for( int j=2;j*j<=999999;j++){
			if(n[j]){
				for(int k=j*2;k<=999999;k+=j){
				n[k]=false;
				}
			}
		}
		while(cin>>a){
	for(int k=2;k<=a;k++) if(n[k]) o++;
	cout<<o<<endl;
	o=0;
		}
}

C++: #include <stdio.h>

const int MAX_V = 1000000;
int prime[MAX_V+1];

void init(){
    int i, k, v;
    for(i=2; i<MAX_V; i++){
        prime[i] = 1;
    }
    for(i=2; i*i<=MAX_V; i++){
        if(prime[i]){
            for(k=2*i; k<=MAX_V; k+=i){
                prime[k]=0;
            }
        }
    }
}

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

int main(){
    init();
    int num;
    while(scanf("%d", &num) != EOF){
        int count=0;
        for(int i=2; i<=num; i++){
            if(isprime(i)==1)
                count++;
        }
    printf("%d\n", count);
    }
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repn(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define lb lower_bound
#define mp make_pair
#define ite iterator
#define max2(x, y) ((x) > (y)) ? (x) : (y)
#define max3(x,y,z) max2((x), max2((y),(z)))
#define max4(v,w,x,y) max2(max2((v),(w)), max2((x),(y)))
#define min2(x, y) ((x) > (y)) ? (y) : (x)
#define min3(x,y,z) min2((x), min2((y),(z)))
#define min4(v,w,x,y) min2(min2((v),(w)), min2((x),(y)))
#define ul unsigned long
#define ull unsigned long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

template<typename T>
bool elem(set<T> st, T val){
	return (st.find(val) != st.end());
}

template<typename T>
void printv(vector<T> vt){
    rep(i, vt.size() - 1)
        cout << vt[i] << " ";
    cout << vt[vt.size() - 1] << endl;
}

typedef vector<int> vint;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef pair<int, int> pii;


vector<int> p;
int main(void){
    p.pb(2);
    for(int i = 3; i <1000000; i += 2){
        int j;
        for(j = 0; p[j] * p[j] <= i; ++j){
            if(i % p[j] == 0) break;
        }
        if(i % p[j] > 0) p.pb(i);
    }
    int n;
    while(cin >> n){
        if(n == 1){
            cout << 0 << endl;
            continue;
        }
        int l = 0, r = p.size();
        while(l + 1 != r){
            int t = (l + r)/2;
            if(p[t] <= n) l = t;
            else r = t;
        }
        int ret = r + 1;
        while(n < p[ret]) ret--;
        cout << ret + 1<< endl;
    }
    return 0;
}

C++: #include <cmath>
#include <cstdio>
#include <map>
 
inline bool fermat_test(int n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else {
        return (static_cast<int>(std::pow(2, n - 1)) % n) == 1;
    }
}
 
inline bool prime_test(int n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else {
        for (int i = 3; i < static_cast<int>(std::sqrt(n)); i += 2) {
            if ((n %= i) == 0) {
                return false;
            }
        }
    }
    return true;
}
 
int main() {
    std::map<int, int> m;
    m[3] = 2;
    int n;
    while (~scanf("%d", &n)) {
        for (int i = 5; i <= n; i += 2) {
            if (m.count(i) > 0)
                continue;
 
            m[i] = m[i - 2] + (fermat_test(i) && prime_test(i));
        }
        printf("%d\n", m[n % 2 == 0 ? n - 1 : n]);
    }
}

C++: int primes[78498], num_primes;
int calculated;
int count_pos(int n) {
	for (int i = 0; i < num_primes; i++) {
		if (primes[i] == n) {
			return i + 1;
		}
		else if (primes[i] > n) {
			return i;
		}
	}
	return num_primes;
}
int main() {
	primes[0] = 2;
	calculated = 2;
	num_primes = 1;
	while (true) {
		int n;
		if (!scanf("%d", &n)) break;
		if (calculated+1 < n) {
			for (int i = calculated + 1; i < n + 1; i += 2) {
				bool is_prime = true;
				int max = (int)(sqrt(i)) + 1;
				for (int j=1; primes[j] < max&&j<num_primes; j++) {
					if (i%primes[j] == 0) {
						is_prime = false;
						break;
					}
				}
				if (is_prime) {
					primes[num_primes++] = i;
				}
			}
			calculated = n - (n % 2);
		}
		printf("%d\n", count_pos(n));
	}
}