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>
using namespace std;

int arr[1000000];

void ar()
{
	int cnt;
	arr[2] = 1;
	int j;
	int i = 3;
	for (; i < 1000000; ++i) {
		cnt = 1;
		for (j = 2; j < i; ++j) {
			if (i%j == 0) {
				arr[i] = arr[i - 1];
				--cnt;
				break;
			}
		}
		arr[i] = arr[i - 1] + cnt;
	}
}

int main()
{
	int x;
	ar();
	while (cin >> x) {
		cout << arr[x] << endl;
	}
	return 0;
}

C++: #include<stdio.h>
const int size=1000000;
int main(){
  int i,k,n;
  int data[size];
  int sum[size];
  for(i=2;i<size;i++){
    data[i]=1;
  }
  for(i=2;i<size;i++){
    if(data[i]){
      for(k=2*i;k<=size;k+=i){
        data[k]=0;
      }
    }
  }
  for(i=2;i<size;i++){
    sum[i+1]=sum[i]+data[i];
  }
  while(scanf("%d",&n)!=EOF){
    printf("%d\n",sum[n+1]);
  }
}

C++: import math
import sys

def prime_calc(n):
    rootN = math.floor(math.sqrt(n))
    prime = [2]
    data = [i + 1 for i in range(2,n,2)]
    while True:
        p = data[0]
        if rootN < p:
            return len(prime + data)
        prime.append(p)
        data = [e for e in data if e % p != 0]

def main():
    l = []

    for line in sys.stdin:
        l.append(line)        

    for line in l:
        print(prime_calc(line))

if __name__ == "__main__":
    main()

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

int count_prime_number(int);

int main(void){

    int n;
    while(scanf("%d",&n) != EOF){
        std::cout << count_prime_number(n) << std::endl;
    }   
                                                                                                                                                               
    return 0;
}

int count_prime_number(int n){ 

    int f,prime_num = 1;

    if (n == 2) {
        prime_num = 1;
    }   
    else{
        for (int j = 3; j <= n; j += 2) {
            f = 0;
            for(int i = 3; i <= std::sqrt(n); i+=2){
                if (j%i == 0) {
                    f = 1;
                    break;
                }
            }   

            if (f == 0) {
                prime_num++;
            }   
        }
    }   

    return prime_num;

}

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

#define MAX 1000000

int main(){
	int i,j,k,n;
	bool arr[MAX];
		i=MAX; while(i--) arr[i]=true;

	while(scanf("%d", &n)!=EOF){

	for(j=2; j<=n; j++){
		if(arr[j]==true){
		for(k=2; j*k<=n; k++){
			arr[j*k]=false;
		}
		}
	}

	for(j=2, k=0; j<=n; j++) if(arr[j]==true) k++;

	printf("%d\n", k);
	}
 return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

#define maxPN 100000
#define PNs  1000100
int countPN = 0, countPNs = 0;
int PrimeNum[maxPN], temp;
bool PN[PNs];

bool IsPrimeNumber(int x);

void PrimeN(){
	int i, j;
	PrimeNum[0] = 2;
	PN[2] = true;PrimeNum[countPN++] = 2;
	PN[3] = true;PrimeNum[countPN++] = 3;
//	PN[5] = true;PrimeNum[countPN++] = 5;
	
	for(i = 6; i  < PNs;i+=6){
		if(IsPrimeNumber(i-1)){
			PrimeNum[countPN++] = i-1;
			PN[i-1] = true;//cout<<i-1<<endl;
		}
		if(IsPrimeNumber(i+1)){
			PrimeNum[countPN++] = i+1;
			PN[i+1] = true;//cout<<i+1<<endl;
		}
		countPNs = i+1;//cout<<i-1<<" "<<PN[i-1]<<endl;
	}
}

bool IsPrimeNumber(int x){
	//if(x == 2 || x == 3) return true;
	//if(x <= 4 || x%2 == 0 || x%3 == 0)   return false;
	//if(x < countPNs) return PN[x];
	for(int i = 0; PrimeNum[i] * PrimeNum[i] <= x; i++)
		if(x%PrimeNum[i] == 0)return false;
	return true;
}


int main(){
//	clock_t start, end;
	int n = true, counta;
//	start = clock();
	PrimeN();
//	cout<<PrimeNum[countPN-1]<<" "<<countPNs<<endl;
//	cout<<clock()-start<<"ms"<<endl;
	
	while(cin>>n){
		counta = 1;
		
		
		//cout<<(IsPrimeNumber(n)?"yes":"no")<<endl;
	//	start = clock();
		//cout<<IsPrimeNumber(n)<<endl;
		for(int i = 1; i <= n; i+=2){
			if(PN[i])counta++;
		//	cout<<i<<" "<<PN[i]<<endl;
		}
		if(n == 1) counta = 0;
		cout<<counta<<endl;
	//	cout<<clock()-start<<"ms"<<endl;
	}
	return 0;
}

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


int main()
{

	int i,n,count;
	deque<int> sosu;
	while(cin >> n){
		if( n <= 2 ) {
			if( n == 2 ) {
				count = 1;
			}
			else 
				count = 0;
		}
		else {
			sosu.push_back(2);
			deque<int>::iterator it;
			bool flg;
			for( i = 3; i <= n ; i+=2 ) {
				flg = false;	
				for(it = sosu.begin(); it != sosu.end(); it++ ) {
					if( i < 2 * (*it) ){
						flg = true;
						break;
					}
					if( i % *it == 0 )
						break;
				}				
				if( flg == true ) {
					sosu.push_back( i );
				}
			}							
			count = sosu.size();
		}
		cout << count << endl;
	}
			
	return 0;
}

C++: #include <iostream>
using namespace std;
int solve(int n){
    int ans,sum=0;
    if(n==1)ans=0;
    else{
        for(int i=1;i<n+1;i++){
            if(n%i==0)sum++;
        }
        if(sum==2)ans=solve(n-1)+1;
        else ans=solve(n-1);
    }
    return ans;
}
int main(void){
    int n;
    while(cin>>n){
        cout<<solve(n)<<endl;
    }
    return 0;
}

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

using namespace std;

vector<int> ary;
const int MAX = 999999;

void generate_prime(int max) {
	bool prime[MAX];

	for(int i = 0; i < max; i++) {
		prime[i] = true;
	}
	prime[0] = false; // 1 is not a prime number

	for(int i = 1; i < sqrt((double)max); i++) {
		if(prime[i]) {
			for(int j = i + 1; (i + 1) * j <= max; j++) {
				prime[(i + 1) * j - 1] = false;
			}
		}
	}

	for(int i = 0; i < max; i++) {
		if(prime[i]) {
			ary.push_back( i + 1 );
		}
	}
}

int main(){
	int n;
	generate_prime(MAX);

	while(cin >> n) {
		vector<int>::iterator it = ary.begin(); 
		int result = 0;

		while(it != ary.end() && *it <= n ) {
			it++;               
			result++;
		}
		cout << result << endl;
	}

	return 0;
}

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

void sieve(int n, list<int> &primes)
{
    vector<bool> v(n / 2 + 1, true);

    // check
    for (int i = 3, end = sqrt(n); i <= end; i += 2) {
        if (!v[i / 2])
            continue;
        for (int j = i * i / 2; j <= n / 2; j += i)
            v[j] = false;
    }

    primes.push_back(2);
    for (int i = 1; i <= n / 2; i++)
         if (v[i])
            primes.push_back(i * 2 + 1);
}

int main()
{
    list<int> primes;
    vector<int> inputs;

    // read all inputs
    for (int x; cin >> x;)
        inputs.push_back(x);

    // init sieve
    sieve(*max_element(inputs.begin(), inputs.end()), primes);

    for (auto x : inputs) {
        int count = 0;
        for (auto p : primes) // find
            if (p == x) {
                count++;
                break;
            } else if (p > x)
                break;
            else
                count++;
        cout << count << endl;
    }

    return 0;
}