Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

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;
        if(n < p[r]) ret = r;
        else ret = l;
        cout << ret << endl;
    }
    return 0;
}

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

int main() {
  int N = 1000000;
  vector<int> table(N, 1);
  table[0] = table[1] = 0;
  for (int i = 2; i * i < N; i++)
    if (table[i])
      for (int j = i * 2; j < N; j += i)
        table[j] = 0;

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

C++: #include <iostream>
#include <math.h>
#define MAX 1000010
using namespace std;

int main(){
	int n;
	int *prime,i,j;
	prime = new int[80000];
	int *answer = new int[MAX];
	int count;
	bool flag;

	count = 1;
	answer[0] = 0;
	answer[1] = 0;
	answer[2] = 1;
	for(i = 3; i <= 1000000; i+=2){
		flag = true;
		for(j = 0; j < count; j++){
			if(i % prime[j] == 0){
				flag = false;
				break;
			}
			if(prime[j] * prime[j] > i) break;
		}
		if(flag == true){
			prime[count++] = i;
		}
		answer[i] = count;
		answer[i+1] = count;
	}
	while((cin >> n)!= NULL){
		cout << answer[n] << endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>
#include<cmath>
#define inf 0x3f3f3f3f
using namespace std;

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

int prime[1000010];
bool IsPrime[1000010];


void init() {
	memset(prime,inf,sizeof(prime));
	memset(IsPrime,true,sizeof(IsPrime));
	int num=0;
	for(int i=2; i<999999; i++) {
		if(IsPrime[i]) {
			prime[num++]=i;
			if(i<=sqrt(999999)) {
				for(int j=i*i; j<999999; j=j+i) {
					IsPrime[j]=false;
				}
			}
		}
	}
}
int main() {

	int x;
	init();
	while(scanf("%d",&x)!=EOF) {
		printf("%d\n",upper_bound(prime,prime+999999,x)-prime);
	}

	return 0;
}

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

using namespace std;

vector<int> PrimeNumber;
int p = 0;

int f(int x){
	if (x == 2) {
		PrimeNumber.push_back(x);
		return 1;
	}
	for (int i = 0; i < PrimeNumber.size(); i++){
		if (x%PrimeNumber[i] == 0) return 0;
	}
	PrimeNumber.push_back(x);
	return 1;
}

int main(){
	long int n;
	int ans = 0;
	while (1){
		cin >> n;
		ans = 0;
		PrimeNumber.clear();
		for (int i = 2; i <= n; i++){
			ans += f(i);
		}
		cout << ans << endl;
	}
}

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

int main() {
  bool check_prime[1000000] = {false};
  int n;

  for (int i=2; i < 1000; i++) {
    if (!check_prime[i]) {
      for (int j = i*i; j < 1000000; j+=i) {
        check_prime[j] = true;
      }
    }
  }

  while (cin >> n) {
    int answer = 0;
    for (int i = 2; i <= n; i++) {
      if (!check_prime[i]) { 
        answer++;
      }
    }
    cout << answer << endl;
  }

  return 0;
}

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

int main(){
	int NUM;
	std::list<int> numList,primeList;
	std::cin >> NUM;
	if(NUM<2){
		return 0;
	}
	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));

	std::cout << primeList.size() << std::endl;

	return 0;
}

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

int main() {
	int N;
	bool is_prime[1000000];
	is_prime[0]=0; is_prime[1]=0;
	for(int i=2;i<1000000; i++){
		is_prime[i]=1;
	}
			
	for(long long s=2; s<1000000; s++){
		if(is_prime[s]==1){	
		for(long long i=s*s; i<1000000; i+=s){
		is_prime[i]=0;	
			
		}
		}
	}
	
	while(cin >> N){
	
		int ans=0;
		for(int i=2; i<N+1; i++){
			ans+=is_prime[i];
		}
		cout << ans <<endl;
		
	}
return 0;
}

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

int main(){

	int i,j,k,n,x;

	while(std::cin >> n){
		x = 1;
		for(i=3;i<=n;i+=2){
			k = 0;
			for(j=3;j<i;j+=2){
				if(i%j == 0){
					k = 1;
					break;
				}
			}
			if(k == 0){
				x++;
			}			
		}
		std::cout << x << std::endl;
	}
}

C++: // #pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
// #define DEBUG
#ifdef DEBUG
#define debug(...) printf( __VA_ARGS__ )
#else
#define debug(...)
#endif
#define MEM(x,y) memset(x, y,sizeof x)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> ii;
const int inf = 1 << 30;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
vector<int> vec;
int a[999999 + 10];
void init(){
	memset(a,0,sizeof a);
	for (int i = 2;i <=  999999 + 9;++i){
		if (a[i] == 0){
			vec.push_back(i);
			for (int j = i + i;j <=  999999 + 9;j += i){
				a[j] = 1;
			}
		}
	}
}
int main()
{	
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	int n;
	init();
	while(scanf("%d",&n) != EOF){
		int ans = upper_bound(vec.begin(), vec.end(),n) - vec.begin();
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int ans,n;
  while (cin >> n) {
    for(int i=2;i<n+1;i++) {
      for(int j=2;j<i+1;j++) {
        if(i == j) {
          ans++;
          break;
        }
        if(i % j ==0) {
          break;
        }
      }


    }
    cout << ans << endl;
    ans = 0;
  }
}