Go: package main

import "fmt"

func main() {
	const MAX = 1000000
	prime := make([]int, MAX, MAX)
	check := make([]int, MAX, MAX)
	count := make([]int, MAX, MAX)

	prime[0] = 1
	prime[1] = 1

	// prime init
	for i := 2; i < MAX; i++ {
		if check[i] == 1 {
			continue
		}

		if prime[i] == 0 {
			for j := i * 2; j < MAX; j += i {
				check[j] = 1
				prime[j] = 1
			}
		}
	}

	for i := 2; i < MAX; i++ {
		cnt := 0

		if prime[i] == 0 {
			cnt = 1
		}

		count[i] = count[i-1] + cnt
	}

	for {
		var input int
		inputCount, _ := fmt.Scanf("%d", &input)
		if inputCount != 1 {
			break
		}

		fmt.Println(count[input])
	}
}

C++: import java.util.Scanner;

public class Main
{

	public static void main(String arg[])
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int count=0;
		for (int i=2; i<=n; i++)
		{
			if(prim(i))
				count++;
		}		
		System.out.println(count);
	}

	public static boolean prim(int a)
	{
		if(a<2)
			return false;
		else if (a==2)
			return true;
		
		for(int j = 2; j<a; j++)
		{
			if(a%j==0)
				return false;
		}
		return true;
	}
}

C++: #include<stdio.h>

int	main(){
	int	i,	k,	x,	cnt[1000001],	data[1000000];
	cnt[0]	=	0;
	data[0]	=	0;
	data[1]	=	0;
	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;
			}
		}
	}
	for(i	=	0;	i	<=	1000000;	i++){
		cnt[i	+	1]	=	cnt[i]	+	data[i];
	}
	while(1){
		scanf("%d",	&x);
		if(x	==	0)break;
		printf("%d\n",	cnt[x]);
	}
	return	0;
}

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

using namespace std;
vector<int> prime;

int calc(int);

int main(){
    int n;
    prime.push_back(2);
    while(-1!=scanf("%d", &n)){
        cout << calc(n) << endl;
    }
    return 0;
}

int calc(int n){
    int lastPrime = prime[prime.size()-1];
    if(n > lastPrime){
        for(int i=lastPrime; i<=n; i++){
            bool isPrime = true;
            for(int j=0; j<prime.size(); j++){
                int checkPrime = prime[j];
                if(i%checkPrime==0){
                    isPrime = false;
                    continue;
                }
            }
            if(isPrime) prime.push_back(i);
        }
        return prime.size();
    }else{
        for(int i=0; i<prime.size(); i++){
            if(prime[i]>=n){
                return i;
            }
        }
    }
    return -1;
}

C++: #include <iostream>

int main(void)
{
	int32_t n = 0;
	int32_t count = 0;
	int32_t count2 = 0;
	bool flag = false;

	while (std::cin >> n)
	{
		count2 = 0;
		for (int i = 2; i <= n; i++)
		{
			flag = false;
			for (int j = i-1; j > 1; j--)
			{
				if (i % j == 0)
				{
					flag = true;
					break;
				}
			}
			if (flag == false)
			{
				count2++;
			}
		}
		std::cout << count2 << std::endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,co=0;
    double he=0;
    while(cin>>n){
        he=sqrt(n);
        int ser[n+1];
        for(int i=2;i<=n;i++)ser[i]=1;
        for(int i=2;i<he;i++)if(ser[i]==1)for(int j=2;j*i<=n;j++)ser[i*j]=0;
        for(int i=2;i<=n;i++)if(ser[i]==1)co++;
        cout<<co<<endl;
        co=0;
    }
}

C++: #include    <iostream>
 
using namespace std;
 
bool F[1000003] = { false };
int DP[80000] = { 0 };
void prepa_Prime();
int count_Prime(int);
 
int main() {
    int n;

    prepa_Prime();
    while (cin >> n) {
        cout << count_Prime(n) << endl;;
    }
    return 0;
}
 
void prepa_Prime() {
    int i, c = 2;

    F[0] = F[1] = true;
    DP[0] = 1;

    DP[1] = 2;
    for (i = 4; i <= 1000003; i += 2) { F[i] = true; }
    
    for (i = 3; i <= 1000003; i += 2) {
        if (F[i] == false) {
            DP[c++] = i;
            for (int j = i * 2; j <= 1000003; j += i) {
                F[j] = true;
            }
        }
    }
}

int count_Prime(int n) {
    int i = 0;
    for (i; DP[i + 1] <= n; i++) {}
    return i;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false


int prime[100000]={0};
int k=1;
void
 makeprime(int n)
{
    prime[0]=2;
    for (int i = 3; i < n; i++)
    {
        double temp = sqrt(i);
        for (int j = 0;; j++)
        {
            if (i % prime[j] == 0)
            {
                break; //this is no prime.
            }
            if (temp < prime[j])
            {
                prime[k++]=i;
                break;
            }
        }
    }
}

int main()
{
    makeprime(999999);
    
    int n;
    int ans=0,i;
    while(cin>>n){
        ans=0;
        i=0;
        while(true){
            if(prime[i]<=n){
                ans++;
            }
            if(n<prime[i]){
                break;
            }
            i++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

int main() {
int a[1000000]{};
bool b[1000000]{};
a[1]=0;
int s=0;
for(int c=2;c<1000000;c++){
	if(!b[c]){
		s++;
		for(int d=c*2;c<1000000;d+=c)b[d]=true;
	}
	a[c]=s;
}
int k;
while(cin>>k){
	printf("%d\n",a[k]);
}
}

C++: #include <iostream>
using namespace std;
const int Max = 10000000;
bool prime[Max];
int main() {
    int in;
    for(int i=0; i<Max; i++) prime[i] = true;
    prime[1] = false;
    for(int i=2; i<Max; i++) {
        if(prime[i]) {
            for(int s=i*2; s<=Max; s+=i) prime[s] = false;
        }
    }
    while(cin >> in) {
        int cnt = 0;
        for(int i=1; i<=in; i++) {
            if(prime[i]) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cmath>
#include<vector>
#define N 999999

using namespace std;

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

  data.push_back(2);
  data.push_back(3);
  for(i=5; i<=N; i+=2){
    for(j=1, isFound=0; data[j]<=sqrt(i); ++j){
      if(i%data[j] == 0){
	isFound = 1;
	break;
      }
    }
    if(isFound == 0) data.push_back(i);
  }

  while(cin >> n){
    for(i=0; i<data.size(); ++i){
      if(n < data[i]) break;
    }
    cout << i << endl;
  }

  return 0;
}

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

int* PrimeCount();

int main()
{
	int n;

	int* a = PrimeCount();

	while (cin >> n) {
		cout << a[n] << endl;
	}

	return 0;
}

int* PrimeCount()
{
	//最大探索値 999999まで
	const int MAX = 1000000;

	//配列全てに1
	array<int, MAX> search;

	for (int i = 2; i < MAX; i++) {
		search[i] = 1;
	}

	for (int i = 2; i < MAX; i++)
	{
		//素数
		if (search[i] == 1)
		{
			//素数の倍数に0
			for (int j = i * 2; j < MAX; j += i)
			{
				search[j] = 0;
			}
		}
	}

	//任意の数字以下での素数の数
	for (int i = 1; i < MAX; i++)
	{
		//1が入ってるとカウントも+1
		search[i] += search[i - 1];
	}

	return &search[0];
}

C++: #include <cstdio>

using namespace std;

int main() {
	long n, m;
	int flag;
	long counter;

	long i, len;
	
    while (scanf("%ld", &n) != EOF) {
        counter = 0;
        m = 2;
        
        while (m <= n) {
            flag = 0;
            len = m / 2;
    
            for(i = 2; i <= len; i++) {
                if(m % i == 0) {
                    flag = 1;
                    
                    break;
                }
            }
    
            if (flag == 0) counter++;
    
            m++;
        }
        
        printf("%ld\n", counter);
    }

    return 0;
}

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

void solve(int n) {
	int i, j, ans = 0;
	for (i = 2; i <= n; i++) {
		int num = 0;
		for (j = 2; j <= i; j++) {
			if (i%j == 0) num++;
		}
		if (num == 1) ans++;
	}
	cout << ans << endl;
}

int main() {
	int n;
	while (cin >> n) {
		cin >> n;
		solve(n);
	}
	return 0;
}