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>

using namespace std;

vector<int> Prime;
void PrimeCalc(int n)
{
	bool IsPrime[1000000];
	for(int i = 0; i < 1000000; ++i)
	{
		IsPrime[i] = true;
	}
	IsPrime[0] = IsPrime[1] = false;
	for(int i = 2; i < 1000000; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 1000000; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	int n;
	cin >> n;
	PrimeCalc(n);
	int ans = 0;
	int pos = 0;
	for(int i = 0; i < Prime.size(); ++i)
	{
		if(Prime[i] <= n)
		{
			++ans;
		}
		else
		{
			break;
		}
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
using namespace std;
#define MAX 10000
bool prime[MAX];
int main(void){ 

  fill(prime,prime+MAX,true);
  prime[0] = prime[1] = false;
  for(int i = 2 ; MAX > i * i ; i ++){
    if(prime[i]){
      for(int j = i + i ; MAX > j * j ; j += i){
	prime[j] = false;
      }
    }
  } 
  int n;
  while(cin>>n,n){
    if(n%2)cout<<"0"<<endl;
    else{
      int cnt = 0,sum = 0;
      for(int i = 0 ; i <= n/2 ; i ++){
	for(int j = i ; j < n ; j ++){
	  if(prime[i] && prime[j]){
	    if(i+j==n)cnt++;
	  } 
	}
      } 
      cout<<cnt<<endl;
    }
  }
}

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

std::vector<std::size_t> prime_table = {2};

void make_prime_table()
{
    std::set<std::size_t> undefined_table;
    for(std::size_t i = 3; i <= 999999; i += 2)
    {
        undefined_table.insert(i);
    }

    const std::size_t sn = 1000;
    for(std::size_t p = 0; !undefined_table.empty() && p < prime_table.size(); ++p)
    {
        for(auto u = undefined_table.begin(); u != undefined_table.end();)
        {
            if(0 == *u % prime_table[p])
            {
                u = undefined_table.erase(u);
            }
            else
            {
                ++u;
            }
        }

        if(!undefined_table.empty())
        {            
            prime_table.push_back(*undefined_table.begin());
            undefined_table.erase(undefined_table.begin());
            if(sn <= prime_table.back())
            {
                break;
            }
        }
    }
    prime_table.insert(prime_table.end(), undefined_table.begin(), undefined_table.end());
}

std::array<std::size_t, 1000000> prime_acc = {{0, 0}};

void make_prime_acc()
{
    std::size_t acc_found = 1;
    for(auto p = prime_table.begin(); p != prime_table.end(); ++p)
    {
        std::fill_n(prime_acc.begin() + acc_found + 1, *p - acc_found - 1, prime_acc[acc_found]);
        acc_found = *p;
        prime_acc[acc_found] = prime_acc[acc_found - 1] + 1;
    }
    std::fill(prime_acc.begin() + acc_found + 1, prime_acc.end(), prime_acc[acc_found]);
}

int main()
{
    make_prime_table();
    make_prime_acc();

    std::size_t n;

    while(std::cin >> n, !std::cin.eof())
    {
        std::cout << prime_acc[n] << std::endl;
    }
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main(){
	int n,k,kk;
	while(cin>>n){
		kk=0;
		for(int j=3;j<=n;j+=2){
			k=0;
			for(int i=3;i<=sqrt(j);i+=2){
				if(j%i==0)k++;
		        }
		     if(k==1)kk++;
		   }
		if(n==1)cout<<"0"<<endl;
		else if(n==2)cout<<"1"<<endl;
		else cout<<kk+1<<endl;
	   }
	return 0;
	}

C++: #include<iostream>
using namespace std;
int prime[1200000];
int main(){
	for(int i=2;i<1200000;i++)prime[i]=1;
	for(int i=2;i*i<1200000;i++){
		for(int j=i*i;j<1200000;j+=i){
			prime[j]=0;
		}
	}
	for(int i=2;i<1200000;i++)prime[i]+=prime[i-1];
	int n;
	while(cin>>n){
		cout<<prime[n]<<endl;
	}
}

C++: #include <iostream>

using namespace std;

bool isPrime(int n){
	
	if (n == 1)
		return false;
	if (n == 2)
		return true;

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

int main(){
	int n;

	while (cin >> n){
		int c = 0;
		for (int i = 1; i <= n;++i){
			if (isPrime(i))
				++c;
		}
		cout << c << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  int i, j, n, isFound;
  vector<int> prime;

  while(cin >> n){
    for(i=2; i<=n; ++i){
      isFound = 1;
      for(j=0; j < prime.size(); ++j){
	if(i % prime[j] == 0){
	  isFound = 0;
	  break;
	}
      }
      if(isFound == 1)
	prime.push_back(i);
    }
    cout << prime.size() << endl;
    prime.clear();
  }

  return 0;
}

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

int num(int n)
{
    int a[1000000] = {1, 1};
    for (int i = 2; i <= n; ++i)
        for (int j = 2; i * j <= n; ++j)
            a[i * j] = 1;
    int cnt = 0;
    for (int i = 0; i <= n; ++i)
        if (a[i] == 0)
            ++cnt;
    return cnt;
}

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

C++: #include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
bool primenum(int a)
{
    int i;
    int s;
    s=(int)sqrt(a)+1;
    if(a==2) return true;
    for(i=2;i<=s;i++)
    {
        if(a%i==0)
        {
            break;
        }
    }
    if(i==s+1)
    {
        return true;
    }
    else
        return false;
}
int main()  
{  
    int n;
    while(cin>>n)
    {

    
        int counter=0;
        for(int j=2;j<=n;j++)
        {
            if(primenum(j))
            {
                counter++;
            }
            
        }
        cout<<counter<<endl;
    }
    //system("pause");
    return 0;
}

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

int main(void) {
    int n;
    while(cin >> n) {
        int a[n];
        for(int i = 0; i <= n; i++) {
            a[i] = 1;
        }
        for(int i = 2; i < sqrt(n); i++) {
            if(a[i]) {
                for(int j = 0; i * (j + 2) <= n; j++) {
                    a[i * (j + 2)] = 0;
                }
            }
        }
        int cnt = 0;
        for(int i = 2; i <= n; i++)
            if (a[i]) cnt++;
        cout << cnt << endl;
    }
}

C++: #include <stdio.h>

int main(void) {

  int n;
  int num;
  int i,p,k,count;
  int flag[1000000];

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

    num=(n-3)/2;

    for(i=0;i<=num;i++) {
      flag[i]=1;
    }

    for(i=0;i<=num;i++) {
      if(flag[i]==1) {
	p=i+i+3;
	printf("%d\n",p);

	for(k=i+p;k<=num;k+=p) {
	  flag[k]=0;
	}
      }
    }
  }

  return 0;
}

C++: #include <iostream>
//#include <stdio.h>
using namespace std;
int main() {
  
  //char str[10];
  long n,i=1,count=0;
  //long exp=1,result[10]={0,0,0,0,0,0,0,0,0,0};

  cin >> n;

  while(i<=n) {
    if(n%i==0) count++;
    i++;
  }

  printf("%ld",count);
  return 0;
}

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

int prime(int x) {
	for (int i = 2; i < sqrt(x) + 1; i++) {
		if (x%i == 0) return 0;
	}
	return 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;
}