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 || num == 5:
		return true
	case num < 2 || num%2 == 0 || num%5 == 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 <iomanip>
#include <cmath>


using namespace std;
#define MAX_NUM 999999


int do_count(bool *isPrime, int n);

int main(){
  int n;
  //?´???°???true,
  bool flag = false;
  bool isPrime[MAX_NUM];


  int pivot = 2;
  
  for(int i=0;i<MAX_NUM;i++){
    isPrime[i] = false;
  }
  
  while(cin >> n){
    int cnt=0;
    //cout << n << endl;
    //    sqrt_n = sqrt(n);
    for(int i=2;i<=n;i++){
      flag = false;
      //?´???°?????????????????§??????
      for(int j=pivot;j<=sqrt(i);j++){
	if(i%j==0){
	  flag = true;
	  break;
	}
      }
      if(flag){continue;}
      isPrime[i]=true;
      //cout << "last: " << i << endl;
    }
    cnt = do_count(isPrime, n);
    //cout << "cnt: " << cnt << endl;
    cout << cnt << endl;
  }
}

int do_count(bool *isPrime, int n){
  int cnt=0;
  for(int i=0;i<=n;i++){
    if(isPrime[i]==true){
      cnt++;
    }
  }
  return cnt;
}

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

bool sieve[1000000];

int main() {
	int n;

	sieve[0] = true;
	sieve[1] = true;

	while (std::cin >> n) {
		if (n <= 1) {
			std::cout << 0 << std::endl;
			continue;
		}

		for (int i = 2; i*i <= n; ++i) {
			if (!sieve[i]) {
				for (int j = i + i; j <= n; j += i)
					sieve[j] = true;
			}
		}

		std::cout << std::count(sieve, sieve + n + 1, false) << std::endl;
	}
}

C++: j,a['   '],s;main(i){for(;++i<1e6||~scanf("%d",&j)&&printf("%d\n",a[j]);)for(s+=!a[j=i];j<1e6;a[i]=s)a[j+=i]=1;}

C++: #include<iostream>
using namespace std;
int main(){
  bool num[1000000] = {false};
  for(int i=2; i<1000; i++){
    if(!num[i]){
      for(int j=i*i; j<1000000; j+=i){
	num[j] = true;
      }
    }
  }
  int n;
  while(cin >>n){
    int sum = 0;
    for(int i=2; i<=n; i++){
      if(!num[i]){sum++;}
    }
    cout <<sum<<endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;
int prime[1000000];

int main(){
	
    prime[0]=-1;
    prime[1]=-1;
    
    for(int i=2;i<1000000;i++){ 
    
        if( prime[i] == 0 ){
        	
            prime[i] = 1;
            for(int j=i*2;j<1000000;j+=i)
			prime[j] = -1 ;
			
        }
        
    }
    int a;
    while( cin >> a ){
    	
        int count = 0;
        
        for(int i=1;i<a+1;i++)
		if(prime[i] == 1)
		count++;
		
        cout << count << "\n";
    }
    return 0;
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
 
int main(){
int n;
 
 
while(cin >> n){
int count =0;
for(int i=2;i<=n;i++){
        for(int j=2;j<=i;j++){
                if(i%j==0 && j != i)    break;
                if(j==i)        count++;
                
                }
        }
 
cout << count << endl;  
 }
return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	long long int N,count[1000000];
		count[1] = 1;
		if(N<0)	break;
	for(int x=2;x<=1000000;x++){
		int flag = 0;
		for(int y=2;y<x;y++){
			if((x%y)==0)	flag = 1;
		}
		if(flag == 0)	count[i] = count[i-1]+1;
	}
	while(cin >> N){
		cout << count[N] << endl;
	}
	return 0;
}

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

int a[1000000];

int main()
{
  int n;
  int count;

  for (int i = 2; i < 1000000; i++){
    a[i] = 1;
  }

  for (int i = 0; i * i < 1000000; i++){
    if  (a[i] == 1){
      for (int j = 2; j * i <= 100000; j++){
        a[j * i] = 0;
      }
    }
  }

  while (cin >> n){
    count = 0;
    for (int i = 0; i < 1000000; i++){
      if (a[i] == 1){
        count++;
      }
    }
  }

  cout << count << endl;

  return (1);
}

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

bool is_prime(int n){
  if(n<=1)
    return false;

  for(int i=2; i*i<=n; i++){
    if(n%i==0)
      return false;
  }

  return true;
}

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[i] = false;
      }
    }
  }

  int n_prime[100000];

  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>
#define N 1000000


using namespace std;
void PrimeNum(int n,bool Primeif[]){
  for(int i = 2;i*i < n;i++){
    if(Primeif[i] == true){
      for(int k = 2;k * i <= n;k++){
	Primeif[k*i] = false;
}
    }
  }
}
int main(){
  int n,num;
  bool Primeif[N+1];
  Primeif[1] = false;
  for(int i = 2;i < N;i++){
    Primeif[i] = true;
  }
  PrimeNum(N+1,Primeif);
  
  while(cin >> n){
    num = 0;
    for(int i = 0;i < n;i++){
      if(Primeif[i] == true){
	num = num+1;
      }
    }
     cout << num << endl;
     
   } 
    
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n,ans;

int main(){
    int N=1000000;
    int prime[N];
    rep(i,N) prime[i] = 1;
    prime[0] = prime[1] = 0;
    rep(i,N){
        if(prime[i]){
            for(int j = i + i; j < N; j+=i){
                prime[j] = 0;
            }
        }
    }
    while(cin>>n){
        ans=0;
        rep(i,n+1)ans+=prime[i];
        out(ans);
    }
}

C++: #include<iostream>
using namespace std;
int main(){
	bool num[1000000] = {0};
	for(int i=2; i<1000; i++){
		if(!num[i]){
			for(int j=i*2; j<1000000; j+=i){num[j] = true;}
		}
	}
	int n;
	while(cin >>n){
		int f = 0;
		for(int i=2; i<=n; i++){
			if(!num[i]){f++;}
		}
		cout <<f<<endl;
	}
}

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

struct IsPrime {
 public:
  explicit IsPrime(int max);
  bool operator()(int n);

 private:
  std::vector<bool> is_prime;
};

IsPrime::IsPrime(int max) : is_prime(max + 1, true) {
  is_prime[0] = false;
  is_prime[1] = false;
  for (auto i = 2; i <= std::sqrt(max); i++) {
    if (!is_prime[i]) {
      continue;
    }

    for (auto mult = 2 * i; mult <= max; mult += i) {
      is_prime[mult] = false;
    }
  }
}

bool IsPrime::operator()(int n) { return is_prime[n]; }

int CountPrime(IsPrime& is_prime, int upto) {
  int cnt = 0;
  for (int i = 2; i <= upto; i++) {
    if (is_prime(i)) {
      cnt++;
    }
  }
  return cnt;
}

int main(void) {
  std::vector<int> inputs;
  int n;
  while (std::cin >> n) {
    inputs.push_back(n);
  }

  int max = *std::max_element(inputs.begin(), inputs.end());
  IsPrime is_prime{max};

  for (auto n : inputs) {
    std::cout << CountPrime(is_prime, n) << '\n';
  }
  return 0;
}