Go: package main

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

func main() {
    var limit = 1000000
    var root = 1000
    var isPrime [1000000]bool
    for i := 0; i < limit; i++ {
        isPrime[i] = true
    }
    isPrime[0] = false
    isPrime[1] = false
    for i := 2; i <= root; i++ {
        if isPrime[i] {
            for j := i * i;j < limit; j+=i {
                isPrime[j] = false
            }
        }
    }
    var primeCnt [1000000]int
    var cnt = 0
    for i := 0; i < limit; i++ {
        if isPrime[i] {
            cnt++
        }
        primeCnt[i] = cnt
    }

    var sc = bufio.NewScanner(os.Stdin)
    for sc.Scan() {
        n, _ := strconv.Atoi(sc.Text())
        fmt.Println(primeCnt[n])
    }
}

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

int a[999999];

int prime(int x) {
	if (a[x] == 1) return 1;
	else if (a[x] == 2) return 0;
	for (int i = 2; i < sqrt(x) + 1; i++) {
		if (x%i == 0) {
			a[x] = 2;
			return 0;
		}
	}
	return a[x]=1;
}
int main(){
	int n;
	while (scanf("%d", &n) != EOF){
		int count = 0;
		for (int i = 2; i <= n; i++) {
			if (prime(i))count++;
		}
		count++;
		if (n == 0)count = 0;
		if (n == 1)count = 0;
		if (n == 2)count = 1;
		printf("%d\n", count);
	}
	return 0;
}

C++: #include <iostream>
#define N 100000
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void)
{
    bool a[N+1];
    int prime[N], n;
    rep(i,N)
    {
        a[i] = true;
    }
    a[0] = a[1] = false;
    for(int i=2;i*i<=N;i++)
    {
        if(a[i])
        {
            prime[i] = prime[i-1] + 1;
            for(int j=i*i;j<N;j+=i)
                a[j] = false;
        }
        else
            prime[i] = prime[i-1];
    }

    while(scanf("%d", &n)!=EOF)
        printf("%d\n", prime[n]);
}

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

int main(){
  int input;
  while(scanf("%d",&input) != EOF){
    int count = 1;
    for(int i = 3;i <= input;i += 2){
      bool isPrime = false;
      for(int s = 3;s <= sqrt((float)i);s += 2){
        if(i % s == 0){isPrime = true; break;}
      }
      if(!isPrime)count++;
    }
    if(input == 2)printf("1\n");
    else if(input < 2)printf("0\n");
    else printf("%d\n",count);
  }

  return 0;
}

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

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

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

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

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

    // 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) {
        for (i = 0; i < primes.size(); i++) // find
            if (primes[i] == x) {
                i++;
                break;
            } else if (primes[i] > x)
                break;
        cout << i << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<string>
int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];std::memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}

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

//using namespace std;

int sosuu(int n);

int main(){
    int n = 0;
    int a[30]={0};
    int b[30]={0};
    int num = 0;
    int max =0;
    
    
    while(scanf("%d",&n)!=EOF){
        a[num]=n;
        if(max<n){
            max=n;
        }
        num++;
    }
    
    int temp = 0;
    for(int i=2; i<=max; i++ ){
        temp+=sosuu(i);
        for(int j=0; j<num; j++ ){
            if(i==a[j]){
                b[j]=temp;
            }
        }
    }
    
    for(int j=0; j<num; j++ ){
        printf("%d\n",b[j]);
    }
    
    
}

int sosuu(int n){
    if(n==2){
        return 1;
    }else{
        int temp=1;
        for(int i=0; i<n; i++){
            temp=temp*2;
        }
        if(temp%n!=2%n){
            return 0;
        }
        return 1;
    }
}

C++: #include<stdio.h>
#include<math.h>
int judge(int x)
{
	if (x == 2)
		return 1;
	for (int i = 2; i < sqrt(x) + 1; i++)
		if (x%i == 0)
			return 0;
	return 1;
}
int main()
{
	int a, num;
	while (scanf("%d", &a) != EOF)
	{
		num = 0;
		for (int i = 2; i <= a; i++)
			if (judge(i))
				num++;
		printf("%d\n", num);
	}
	return 0;
}

C++: #include<iostream>

using namespace std;



bool Prime(int n)
{
	if((n==1)||(n==0))
	{
		return false;
	}
	for(int i=2;i<=n-1;++i)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}

void main()
{
	int n;
	while(cin>>n)
	{
		int count = 0;
		for(int i=0;i<=n;++i)
		{
			if(Prime(i))
			{
				++count;
			}
		}
		cout<<count<<endl;
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

using namespace std;

int main()
{
	int n,ans,flag;

	while(scanf("%d",&n)!=EOF){
		ans=0; 
		for(int i=2;i<=n;i++){
			flag=1;
			for(int j=2;j*j<=i;j++){
				if(i%j==0) {flag=0;break;}
			}
			if(flag) ans++;
		}
		cout<<ans<<endl;
	}

	return 0;
}

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

int main(){
  int a,j,cou;
  while(cin>>a){
    cou=0;
    for(int i=2;i<=a;i++){
      if(i==2){
	cou++;
	continue;
      }
      else if(i%2==0)continue;
      for(j=3;j*j<=i;j+=2)if(i%j==0)break;
      if(j*j>i)cou++;
    }
    cout <<cou<<endl;
  }
  return 0;
}

C++: #include <iostream>

bool divisible( int u, int v )
{
    return (u % v) == 0 ? true : false;
}

int num_divisors( unsigned int start, unsigned int end )
{
    if ( start == end ) return 1;
    return divisible( end, start ) + num_divisors( start+1, end );
}

int no_of_divisor( unsigned int n )
{
    return num_divisors( 1, n );
}

bool is_prime( unsigned int n )
{
    return (no_of_divisor(n) == 2);
}

int count_prime( unsigned int n )
{
    int count = 0;
    for ( unsigned int i = 1; i <= n; ++i )
    {
        if ( is_prime(i) ) ++count;
    }
    return count;
}

int main()
{
    int n;
    while( std::cin >> n)
        std::cout << count_prime(n) << std::endl;
    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;
}