Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func isPrime(n int) bool {
	for i := 2; i*i <= n; i++ {
		if n % i == 0 {
			return false
		}
	}
	return true
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		cnt := 0
		for i := 2; i <= n; i++ {
			if isPrime(i) {
				cnt++
			}
		}
		fmt.Println(cnt)
	}
}

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

using namespace std;

int main() {
  const int N_MAX = 999999;
  const double MAX = sqrt(N_MAX);

  vector<int> preprime_list, prime_list;

  for (int i = 2; i <= N_MAX; i++) {
    preprime_list.push_back(i);
  }

  while (preprime_list[0] < MAX) {
    for (int i = 1; i < preprime_list.size(); i++) {
      if (preprime_list[i]%preprime_list[0] == 0)
        preprime_list.erase(preprime_list.begin()+i);
    }
    prime_list.push_back(preprime_list[0]);
    preprime_list.erase(preprime_list.begin()+0);
  }
  prime_list.insert(prime_list.end(), preprime_list.begin(), preprime_list.end());

  int data,count;
  while (cin >> data) {
    for (int i = 0; i < prime_list.size() && prime_list[i] <= data; i++, count = i);
    cout << count << endl;
  }
}

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

using namespace std;
int main(){
  
 int input;
 while(cin >> input){
 int res = 0;
 int   flag = 0;
 for (int i = 2; i <= input; ++i){
     for (int j = 2; j < i; ++j){
         if (i % j == 0){
             flag = 1;
         }
     }
         if (flag == 0){
             res++;
         }else{
             flag = 0;
         }
     
 }
 cout << res << endl;
}
}

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

int Era(int N) {
	int prime_num = 0;
	int* array = new int[N + 1];
	for (int i = 2; i < N + 1; i++) {
		array[i] = 1;
	}
	for (int i = 2; i <= sqrt(N); i++) {
		if (array[i]) {
			for (int j = 0; i*(j + 2) <= N; j++) {
				array[i*(j + 2)] = 0;
			}
		}
	}
	for (int i = 2; i < N + 1; i++) {
		if (array[i])prime_num++;
	}
	return prime_num;
}

int main() {
	int num;
	while (cin >> num) {
		cout << Era(num) << endl;
	}
	return 0;
}

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

int main()
{
 bool prime[10000000];

 prime[0]=prime[1]=false;
 for(int i=2;i<10000000;i++){
	prime[i]=true;
 }
 for(int i=2;i*i<10000000;i++){
	if(prime[i]){
		for(int j=i*i;j<10000000;j+=i){
			prime[j]=false;
		}
	}
 }
//???????????§?´???°??¨
 int n=0;
 int x=0;
 
 
 while(1){
	cin>>n;
  if(n==0)break;
	for(int i=n;i>10;i--){
		if(prime[i-8]&&prime[i-6]&&prime[i-2]&&prime[i]){
			cout<<i<<endl;
			break;
		}
	}
 }


 return 0;
}

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

int get_num_of_under_n(int n) {
	bool* numbers = new bool[n + 1];
	for (int i = 2; i < n + 1; i++) {
		numbers[i] = true;
	}
	for (int i = 2; i <= sqrt(n); i++) {
		if (numbers[i] == true) {
			for (int j = 0; i*(j + 2) <= n; j++) {
				numbers[i*(j + 2)] = false;
			}
		}
	}
	int ans = 0;
	for (int i = 2; i < n + 1; i++) {
		if (numbers[i] == true)ans++;
	}
	return ans;
}
int main() {
	int n;
	while (cin>>n) {
		cout << get_num_of_under_n(n)<<endl;
	}
}

C++: //	created : 16/03/06
// 	autor   : Rp7rf
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF 1e9
#define MAX 999999 + 10
bool prime[MAX];
int cnt[MAX];

void init_prime(){
	rep(i,MAX){
		prime[i] = true;
		
	}
	prime[0] = prime[1] = false;
	int c = 0;
	rep(i,MAX){
		if(prime[i]){
			for(int j = i + i ; j < MAX ; j += i){
				prime[j] = false;
			}
			c++;
		}
		cnt[i] = c;

	}
}

int main(void){
	init_prime();
	int n ;
	while(cin>>n){
		cout<<cnt[n]<<endl;
	}
}

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

int main() {
	int n;
	while (cin >> n) {
		int  i, j, p;
		p = 0;
		bool isprime[1000000];
		for (i = 0; i <= n; i++) {
			isprime[i] = true;
		}
		isprime[0] = false;
		isprime[1] = false;
		for (j = 2; j <= n; j++) {
			if (isprime[j]) {
				for (i = 2; i*j <= n; i++) {
					isprime[i*j] = false;
				}
				p++;
			}
		}
		cout << p << endl;
	}
	return 0;
}

C++: //--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.rbegin(),v.rend())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;

bool is_prime(int a) {
	int now = 2;
	while (now*now <= a) {
		if (a%now == 0)return 0;
		else now++;
	}
	return 1;
}


int main() {
	while (cin >> n) {
		ll ans = 0;
		bool a[1000001];
		for (int i = 0; i < 1000001; i++)a[i] = 0;
		for (int i = 2; i <= n; i++) {
			if (a[i] != 1)ans++;
			for (int j = i; j <= n; j += i) {
					a[j] = 1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include "stdio.h"
//#include"time.h"
const int MAX_V = 1000000; // 100????????§????´???°??¨?????????
int prime[MAX_V+1]; // 1????´???°,0????´???°??§?????????
int main() {
    int i, k, n;
//    clock_t start, now;//??£?¨?
    for(i = 2; i <= MAX_V; i++){
        prime[i] = 1; // 2??\???????´???°??¨??????
    }
    for(i = 2; i * i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°???2?????\???????????°????´???°??§?????????
            }
        }
    }
    int sum[1000000] = {0};
    while (1) {
        scanf("%d",&n);
        for(k = 0;k <= n;k++){
            if (n == EOF)break;
            sum[k+1] = sum[k] + prime[k];
//        start = clock(); // ????§???????
//        now = clock(); // ????????????
        }
        printf("%d\n",sum[n+1]);//for?????????????????????
//        printf("%f\n", (double)(now - start) / CLOCKS_PER_SEC);
    }
    return 0;
}
//????¨??????¨????????????????????????

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;

int t;

int main(){
	int *prime;
	prime = (int *)malloc(1000010*sizeof(t));
	if(prime==NULL) cout<<"no mem\n";
	rep(i,1000010){
		prime[i]=true;
	}
	prime[0]=prime[1]=false;
	for(int i=2;i*i<1000010;i++){
		if(prime[i]){
			for(int j=i*i;j<1000010;j+=i){
				prime[j]=false;
			}
		}
	}
	
	int *sum;
	int num=0;
	sum=(int *)malloc(1000010*sizeof(t));
	if(sum==NULL) cout<<"no mem\n";
	rep(i,1000010){
		if(prime[i]){
			num++;
		}
		sum[i]=num;
	}
	int n;
	while(cin>>n){
		cout<<sum[n]<<endl;
	}
	return 0;
}