Go: package main

import (
  "fmt"
  "math"
)

func main() {
  const N = 1000000
  var temp [N+1]bool
  for i:=0; i<N+1; i++ {
    temp[i] = true
  }
  temp[0] = false
  temp[1] = false
  for i:=2; i<int(math.Ceil(math.Sqrt(float64(N+1)))); i++{
    if (temp[i]){
      for j:=i*2; j<N+1; j+=i{
        temp[j] =false
      }
    }
  }
  var a int
  var b int
  for _, err := fmt.Scan(&a); err == nil; _, err = fmt.Scan(&a) {
    b = 0
    for i:=0; i<=a; i++{
      if temp[i] {
        b++
      }
    }
    fmt.Println(b)
  }
}

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

int main()
{
 bool prime[1000000];

 prime[0]=prime[1]=false;
 for(int i=2;i<1000000;i++){
	prime[i]=true;
 }

 for(int i=2;i*i<1000000;i++){
	if(prime[i]){
		for(int j=i*i;j<1000000;j+=i){
			prime[j]=false;
		}
	}
 }

 int n_prime[1000000];
 int cnt=0;
 for(int i=0;i<1000000;i++){
	if(prime[i]){
		cnt++;
	}
 	n_prime[i]=cnt;
 }

 while(true){
	int n;
	cin>>n;
	if(cin.eof()){
		break;
	}
	if(n==0){
		break;
	}
	cout<<"??¬?´???°?????°???"<<n_prime[n]<<endl;
 }
 return 0;
}

C++: #include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
using namespace std;

//int is_prime(int N){
//
//	int root = sqrt(N);
//	int i;
//	for(i = 3; i<= root; i+=2){
//		if(N%i==0)
//			return 0;
//	}
//	if(i>root)
//		return 1;
//}


bool isPrime(int num) {
    if (num <= 3) {
        return num > 1;
    } else if (num % 2 == 0 || num % 3 == 0) {
        return false;
    } else {
		int root = sqrt(num);
        for (int i = 5; i <= root; i += 6) {
            if (num % i == 0 || num % (i + 2) == 0) {
                return false;
            }
        }
        return true;
    }
}

int main(){

	int A;
	int count = 1;



	while( scanf("%d", &A) != EOF ){
		count = 1;

		if(A<2) count=0;
		else if (A==2) count=1;
		else{
			for(int i=3; i<=A; i+=2){
				if(isPrime(i) == true)
					count++;
			}
		}

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


	return 0;
}

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

int f[1000001];
int main(){
    fill_n(f,1000001,1);
    f[0]=f[1]=0;
    
    for(int i=2;i<1000001;i++){
        f[i]+=f[i-1];
        if(!f[i])continue;
        for(int j=i+i;j<1000001;j+=i)f[j]=0;
    }
    
    int N;
    
    while(scanf("%d",&N),&N){
        printf("%d\n",f[N]);
    }
    
    return 0;
    
}

C++: #include<stdio.h>

int	main(){
	int	i,	k,	x,	cnt,	data[1000000];
	for(i	=	2;	i	<=	1000000;	i++){
		data[i]	=	1;
	}
	for(i	=	2;	i	*	i	<=	1000000;	i++){
		if(data[i]){
			for(k	=	2	*	i;	k	<=	1000000;	k	+=	i){
				data[k]	=	0;
			}
		}
	}
	while(1){
		cnt	=	0;
		scanf("%d",	&x);
		if(x	==	0)break;
		for(i	=	2;	i	<=	x;	i++){
			if(data[x]	==	1)cnt++;
		}
		printf("%d\n",	cnt);
	}
	return	0;
}

C++: #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <functional>

using namespace std;

#define MAXN 1000016

int isprime[MAXN];

void sieve(int n)
{
	int i, j, num, p = 0;
	fill(isprime, isprime + MAXN + 1, 1);
	for (i = 2, num = 1; i <= n; i++)
	{
		if (isprime[i])
		{
			isprime[i] = num++;
			for (j = 2 * i; j <= n; j += i)
				isprime[j] = 0;
		}
	}
}

int main()
{
	int n;
	sieve(MAXN);
	while (scanf("%d", &n) != EOF)
	{
		while (!isprime[n])
		{
			n--;
		}
		printf("%d\n", isprime[n]);
	}
	return 0;
}

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

int main(){
	int n;
	while(cin >> n){
		int counter = 0;
		if(n != 1)counter++;
		for(int i = 3; i <= n; i += 2){
			for(int j = 2; j <= sqrt(i); j++){
				if(i % j == 0)goto divisible;
			}
			counter ++;
			divisible:;
		}
		cout << counter << endl;
	}
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

bool prime[(int)1e7];
int integral[(int)1e7];

int main(){
	fill(prime + 2, prime + (int)1e7, true);
	
	for(int i = 2; i < (int)1e7; ++i){
		if(prime[i]){
			for(int j = i * 2; j < (int)1e7; j += i){
				prime[j] = false;
			}
		}
	}

	for(int i = 1; i < (int)1e7; ++i){
		integral[i] = integral[i - 1] + prime[i];
	}

	int n;
	while(scanf("%d", &n) != EOF){
		printf("%d\n", integral[n]);
	}
	return 0;
}

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

using namespace std;

#define MAX_NUM	1000000

int solist[MAX_NUM] = { 0 };

int main(int argc, char* argv[])
{
	int i; 
	int num;
	int count;
	int val;

	solist[0] = 1;
	solist[1] = 1;

	for (num = 2; num < MAX_NUM; num++) {
		if (solist[num]) continue;
		for (i = num * 2; i < MAX_NUM; i += num) {
			solist[i] = 1;
		}
	}

	while (cin >> val) {
		count = 0;
		for (i = 1; i <= val; i++) {
			if (solist[i] == 0) {
				count++;
			}
		}
		cout << count << endl;
	}
	
	return 0;
}

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

 void prima()
    {
        bool isprima;
        int a, n;
        while(cin >> a)
        {
            n = 0;
            for(int i = 2; i <= a; i++)
            {
                isprima = true;
                for(int j = 2; j < i; j++)
                {
                    if( i == 2)
                    {
                        isprima = true;
                        break;
                    }
                    else if(i % j == 0)
                    {
                        isprima = false;
                        break;
                    }
                }
                if(isprima) n++;
            }
            cout << n << endl;
        }
    }

int main()
{
   prima();
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a[999999];
	a[0] = 2;
	long long k = 1;
	for (long long i = 2; i<=999999; i++)
	{
		int flag = 1;
		for (long long j = 2; j <= sqrt(i) + 1;j++)
		{
			if (i%j == 0)
			{
				flag = 0;
				break;
			}
		}
		if (flag)
			a[k] = i, k ++ ;
	}
	int n;
	while (cin >> n)
	{
		long long ans = 0;
		for (long long x = 0; x < k; x++)
		{
			if (n >= a[x])
				ans++;
			else
				break;
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

void Eratosthenes(vector<int> &S_List, vector<int> &P_List){
	while(1){
		vector<int>::iterator it = S_List.begin();
		P_List.push_back(*it);  //先頭を素数リストへ追加
		int num = *it;
		while (it != S_List.end()){
			if ((*it % num) == 0){
				it = S_List.erase(it); //探索リストから倍数を除外
			}
			else{
				++it;
			}
		}
		vector<int>::iterator P_it = max_element(P_List.begin(), P_List.end());
		double p_max_sqr = sqrt(*P_it);
		vector<int>::iterator S_it = max_element(S_List.begin(), S_List.end());
		if (S_List.empty() == true){
			return;
		}
		if (*S_it < p_max_sqr){
			return;
		}
		/*else{
			Eratosthenes(S_List, P_List);
		}*/
	}
}


void output(vector<int> ex){
	/*vector<int>::iterator it = ex.begin();
	while(it != ex.end()){
		cout << *it << endl;
		++it;
	}*/
	cout << ex.size() << endl;
}

int main(void){
	int num;
	while (cin >> num){
		vector<int> S_List, P_List;
		for (int i=2; i<=num; ++i){
			S_List.push_back(i);
		} 
		Eratosthenes(S_List, P_List);
		output(P_List);
	}
	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(cin >> n)
        cout << prime[n] << endl;
    
    return 0;
}