Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

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

const int MAX_VALUE = 1000000;

class PrimeNumbers
{
public:
	vector<bool> primeNumbers;

	PrimeNumbers()
	{
		this->createPrimeNumbers();
	}
	
	int answer(int N)
	{
		int result = 0;
		for (int i = 0; i <= N; i++)
		{
			if (this->primeNumbers[i])
			{
				result++;
			}
		}
		return result;
	}

	void createPrimeNumbers()
	{
		
		this->primeNumbers = vector<bool>(MAX_VALUE, true);
		this->primeNumbers[0] = false;
		this->primeNumbers[1] = false;
		for (long long i = 2; i < MAX_VALUE; i++)
		{
			for (long long j = i * i; j < MAX_VALUE; j += i)
			{
				this->primeNumbers[j] = false;
			}
			
		}
	}

};

int main()
{
	int N;
	PrimeNumbers pn = PrimeNumbers();
	
	while(cin >> N)
	{
		cout << pn.answer(N) << endl;
	}
	return 0;
}

C++: #include <stdio.h>
 
int main(){
    int e[30];
 
    int k = 0;
    while( scanf( "%d",&e[k] ) != EOF )k++;
 
    for( int i = 0;i < k;i++ ){
        int n = 1;
        int k = 0;
        while( true ){
            if( e[k] => n ){
                k++;
                n *= 10;
            } else {
                break;
            }
        }
        printf( "%d\n",k );
    }
    return 0;
}

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

using namespace std;
static const int MAXV = 1000000;

int sosuu_list[MAXV];

void make_sosuu_list() {
  for(int i=0;i<MAXV;i++) sosuu_list[i] = 1;
  sosuu_list[0] = sosuu_list[1] = 0;
  for(int i=2;i<MAXV;i++) {
    if(sosuu_list[i]) {
      for(int j=i+i;j<MAXV;j+=i) sosuu_list[j] = 0;
    }
  }
  for(int i=1;i<MAXV;i++)sosuu_list[i]+=sosuu_list[i-1];
}

int main() {
  int n;
  make_sosuu_list();
  while(/*scanf("%d", &n) == 0) {*/!feof(stdin)) {
    scanf("%d", &n);
    if(feof(stdin)) break;
    printf("%d\n", sosuu_list[n]);
  }
}

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

int main(){
  int n,prime[1000001],key,lf=0;
  prime[0]=2;
  key=1;
  for(int i=3;i<=1000100;i+=2)
    {
      for(int j=2;j<=sqrt(i);j++)
	{
	  if(i%j == 0)
	    {
	      lf=1;
	      break;
	    }
	}
      if(lf == 1)
	{
	  lf=0;
	}
      else 
	{
	  prime[key]=i;
	  key++;
	}
    }

  while(cin >> n)
{
  int cou=0;
  for(int i=0;;i++)
    {
      if(prime[i] <= n)
	{
	  cou++;
	}
      else break;
    }

  cout << cou << endl;
 }
}

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

int main()
{
	int n,c;

	while(cin >> n){
		c = 0;
		bool flag = false;

		for(int i=2;i<n+1;++i){
			for(int j=2;j<i;++j){
				if(i%j == 0)
					flag = true;
			}

			if(!flag)
				++c;
			flag = false;

		}

		cout << c << endl;

	}
	return 0;
}

C++: #include <iostream>

bool Check(int);

int main(void)
{
    int input;
    int count;
    for(int i=0;i < 30;++i){
        std::cin >> input;
        count = 0;
        for(int j=2;j <= input;++j){
            if(Check(j)){
                ++count;
            }
        }
        std::cout << count << std::endl;
    }
    return 0;
}
bool Check(int value)
{
    bool result = true;
    for(int i=value / 2;i >= 2;--i){
        if(value % i == 0){
            result = false;
            break;
        }
    }
    return result;
}

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

int main() {
	int n;
	while(cin >> n && n != EOF) {
		bool* prime = new bool[n+1];
		int count = 0;
		for(int i = 0; i <= n; ++i) {
			prime[i] = true;
		}
		prime[0] = prime[1] = false;
		
		for(int i = 0; i <= n; ++i) {
			if(prime[i]) {
				cout << i << '\t';
				for(int j = 2 * i; j <= n; j += i) {
					prime[j] = false;
				}
			}
		}
		
		for(int i = 0; i <= n; ++i) {
			if(prime[i]) {
				count++;
			}
		}
		
		cout << count << endl;
		delete[] prime;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
    int a[80000];
    int n;
    a[0]=2;
    int k=1;
while(cin>>n){
    for(int i=3;i<=n;i+=2){
        for(int j=0;j<=k;j++){
            if(j==k){
                a[k]=i;
                k++;
                break;
             }
            if(i%a[j]==0)break;
        }
    }
    cout<<k<<endl;
    k=1;
 }
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN = 1000000+1000;
const int maxn=1000000+5;
int prime[maxn];
bool p[MAXN];
int cnt=0;
void getPrime()
{
    memset(p,true,sizeof(p));
    p[0]=p[1]=false;
    for(int i=2;i<=MAXN;i++)
       if(p[i]) {
       	prime[cnt]=i;
       	cnt++;
       	for(int j=i*i;j<=MAXN;j+=i)
       	    p[j]=false;
	   }
}
int main()
{
	getPrime();
	/*int k=lower_bound(prime,prime+cnt,999999)-prime;
	for(int i=k;i>=0;i--)
	   if(prime[i]<999999) {
	   	printf("%d\n",i+1);
	   	break;
	   }*/
	/*for(int i=0;i<cnt;i++)
	   cout<<prime[i]<<" ";*/
	int n;
	while(scanf("%d",&n)==1){
		int k=lower_bound(prime,prime+cnt,n)-prime;
		if(prime[k]==n) k++;
		printf("%d\n",k);
	}
	return 0;
}

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

class PrimeBox
{
private:
	bitset<1000000> m_box;
	size_t m_size;

public:
	PrimeBox() :
		m_box(),
		m_size(2)
	{
		m_box.set();
		m_box.reset(0);
		m_box.reset(1);
	}

private:
	void expand(size_t size)
	{
		for(size_t i = m_size + 1; i <= size; i++)
		{
			for(size_t j = 2; j < i; j++)
			{
				if(!m_box.test(j))
					continue;

				if(i % j == 0)
				{
					m_box.reset(i);
					break;
				}
			}
		}
		m_size = size;
	}

public:
	bool isPrime(size_t number)
	{
		if(m_size < number)
			expand(number);

		return m_box.test(number);
	}
};

int main()
{
	PrimeBox box;

	size_t n;
	while(cin >> n)
	{
		int found = 0;
		for(size_t i = 2; i <= n; i++)
		{
			if(box.isPrime(i))
				found++;
		}

		cout << found << endl;
	}

	return 0;
}

C++: #include <stdio.h>

int main(void) {

  int n;
  int num;
  int i,flag,count;

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

    count=0;

    for(num=1;num<=n;num++) {

      flag=1;

      for(i=2;i<num/2+1;i++) {
	if(num%i==0) {
	  flag=0;
	  break;
	}
      }
      
      if(num==1) flag=0;

      if(flag==1) {
	printf("%d\n",num);
	count++;
      }
    }

    printf("%d\n",count);

  }

  return 0;
}