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>
#include<cstdio>
#include<fstream>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<ctime>
#include<climits>
#include<ctype.h>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
#define PI acos(-1.0)
#define eps 1e-12
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ll N = 1e6+1;
const int MOD = 1e9+7;
bool flag = true;
int prime[N];
bool check[N]{0};
int main()
{
	//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
	//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
	//%%%llaa
    int i,j,n,tot=0;
    for(i=2;i<N;i++)
    {
        if(!check[i])
        {
            prime[tot++]=i;
            for(j=i+i;j<N;j+=i)
                check[j]=1;
        }
    }
    int p=30;
    while(~scanf("%d",&n)&&p)
    {
        p--;
        int num=0;
        i=0;
        while(prime[i++]<=n)
            num++;
        printf("%d\n",num);
    }
	return 0;
}


/*

*/

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int keta(int x){
	int i=0;
	while (x/pow(10,i)>=1){
		i++;
	}
	if (x==0){
		return 1;
	}
	else
	return i;
	}


int main(){
int n;
while (cin>>n){
	int yakusu=0;
	for (int i=2;i<=n;i++){
		bool flag=true;
		for (int j=2;j<i-1;j++){
			if(i%j==0){
				flag=false;
			}
		}
		if (flag){
		yakusu++;
		}

	}
cout<<yakusu<<endl;
}
	}

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

typedef long long LL;
using namespace std;

const int X = 10000001;
bool isPrime[X];

void init(){
  for(int i=0;i<X;i++){
    isPrime[i] = false;
  }
  isPrime[2] = true;
  for(int i=3;i<X;i+=2){
    cout << i << endl;
    bool ok = true;
    for(int j=2;j<=sqrt(i);j++){
      if(!isPrime[j])continue;
      if(i%j==0)ok=false;
    }
    if(ok)isPrime[i] = true;
  }
}

int main(){
  init();
  int n;
  while(cin >> n){
    int answer = 0;
    for(int i=0;i<n+1;i++){
      if(isPrime[i])answer++;
    }
    cout << answer << endl;
  }
  return 0;
}

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

int main() {
	vector<int> primes;
	primes.push_back(2);
	primes.push_back(3);
	for (int n = 4; n != 1000; ++n) {
		bool isPrime = true;
		for (int i = 0; i != primes.size(); ++i) {
			if (n % primes[i] == 0) {
				isPrime = false;
			}
		}
		if (isPrime) {
			primes.push_back(n);
		}
	}

	int n;
	while (cin >> n) {
		int count = 0;
		for (int i = 0; i != primes.size(); ++i) {
			if (primes[i] <= n)
				++count;
			else 
				break;
		}
		cout << count << endl;
	}

	return 0;
}

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

int main()
{
	int counter=1,n,flag;
	
	while(cin>>n)
	{
		if(n<=1) 
		{
			cout<<'0'<<endl;
			break;
		}

		for(int i=3;i<=n;i+=2)
		{
			flag=1;
			for(int j=3;j<=sqrt(i);j+=2)
				if(i%j==0)
				{
					flag=0;
					break;
				}
			if(flag==1)
				counter++;
			flag=1;
		}
		cout<<counter<<endl;
		counter=0;
	}
}

C++: #include <iostream>

int prime_numbers[999999];
int cur_index = 4;

bool is_prime(int p) 
{
    for (int i = 0; i < cur_index; i++) {
        if (p % prime_numbers[i] == 0) {
            return false;
        }
    }
    return true;
}

int main(void)
{
    prime_numbers[0] = 2;
    prime_numbers[1] = 3;
    prime_numbers[2] = 5;
    prime_numbers[3] = 7;

    long long int n;
    std::cin >> n;

    for (int i = 8; i <= n; i++) {
        if (is_prime(i)) {
            prime_numbers[cur_index] = i;
            cur_index++;
        }
    }

    std::cout << cur_index << std::endl;
    return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
bool prime(int num){
	if(num<2)return false;
	else if(num==2)return true;
	else if(num%2==0)return false;
	double sqrtNum = sqrt((double)num);
	for(int i=3;i<=sqrtNum;i++){
		if(num%i==0)return false;
	}
	num=0;
	return true;
}
int main(){
	int n,count=0;
	while(cin>>n){
		for(int ii=1;ii<=n;ii++){
		count+=prime(ii);
		}
		cout<<count<<endl;
		count=0;
	}
	return 0;
}