Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

C++: #include <iostream>                                                                                                       
#include <vector>                                                                                                         
#include <list>                                                                                                           
                                                                                                                          
#define MAX 1000000                                                                                                       
                                                                                                                          
using namespace std;                                                                                                      
                                                                                                                          
int main() {                                                                                                              
  vector<int> prime_numbers;                                                                                              
  prime_numbers.push_back(2);                                                                                             
  prime_numbers.push_back(3);                                                                                             
  prime_numbers.push_back(5);                                                                                             
  prime_numbers.push_back(7);                                                                                             
                                                                                                                          
  list<int> search_list;                                                                                                  
  for (int i = 5; i < MAX; i++) {                                                                                         
    if (i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0) {                                                           
      search_list.push_back(i);                                                                                           
    }                                                                                                                     
  }                                                                                                                       
  int h = search_list.front();                                                                                            
  while (h * h < search_list.back()) {                                                                                    
    prime_numbers.push_back(h);                                                                                           
    list<int>::iterator itr = search_list.begin();                                                                        
    while (itr != search_list.end()) {                                                                                    
      if (*itr % h == 0) {                                                                                                
        itr = search_list.erase(itr);                                                                                     
      } else {                                                                                                            
        itr++;                                                                                                            
      }                                                                                                                   
    }                                                                                                                     
    h = search_list.front();                                                                                              
  }                                                                                                                       
  for (list<int>::iterator itr = search_list.begin(); itr != search_list.end(); itr++) {                                  
    prime_numbers.push_back(*itr);                                                                                        
  }                                                                                                                       
                                                                                                                          
  int n;                                                                                                                  
  while (cin >> n) {                                                                                                      
    int count = 0;                                                                                                        
    for (vector<int>::iterator itr = prime_numbers.begin(); itr != prime_numbers.end(); itr++) {                          
      if (*itr >= n) break;                                                                                               
      count++;                                                                                                            
    }                                                                                                                     
    cout << count << endl;                                                                                                
  }                                                                                                                       
                                                                                                                          
  return 0;                                                                                                               
}

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

int main(){
	int n;
	while(cin >> n){
		bool* p = new bool[n+1];
		int cou = 0;
		for(int i = 0; i < n+1; ++i){
			p[i] = true;
		}
		p[0] = false; p[1] =false;
		for(int i = 2; i*i <= n; ++i){
			for(int j = 2;i*j <= n ; ++j) {
				p[i*j] = false;
			}
		}

		for(int i = 0; i < n+1; ++i ){
			if(p[i] == true) ++cou;
		}
		cout << cou << endl;
	}
    return 0;
}

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

using namespace std;


// cin >>
// cin <<
bool isPrime(int x){
	if(x==2) return true;
	if(x<2||x%2==0) return false;
	int i=3;
	while(i<=sqrt(x)){
		 if (x%i==0)return false;
		i= i+2;
	}
	return true;
}
int main(){
	int in[30]={};
	int out=0;
	for(int i=0;i<30;i++) cin >>in[i];
	for(int i=0;i<30;i++){
		if(in[i]==0){
			break;
		}else{
			out=0;
			for(int j=0;j<in[i]+1;j++){
				if(isPrime(j)==true){
					out++;
				}
			}
			cout <<out<<endl;
		}
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int PrimeNum(int n){
  for(int i = 2;i*i <= n;i++){
    if(i == n){
      return 1;
    }
    if(i*i == n){
      return 0;
    }
  }
}
int main(){
  int n,num;
   while(cin >> n){
    num = 0;
     for(int k = 2;k <= n;k++){
       if(PrimeNum(k) == 1){
	 num = num +1;
       } 
     }
     cout << num << endl;
     }
}