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++: #include<iostream>
#include<string>
#include<cmath>
using namespace std;

int main()
{
	
	long int k,p[100000];
	float n;
	p[0]=2;
	while(cin>>n){
		if(n<0){
			break;
		}
	k=0;
	int r=(int)sqrt(n);
	for(int i=3;i<=r;i++){
		for(int j=0;j<k+1;j++){
			if(i%p[j]==0){
				break;
			}else if(j==k){
				k++;
				p[k]=i;
			}
		}
	}
	int r_k=k;
	for(;r<n;r++){
		for(int i=0;i<=r_k;i++){
			if(r%p[i]==0){
				break;
			}else if(i==r_k){
				k++;
			}
		}
	}
	if(k!=0&&k!=1){
		k+=1;
	cout<<k<<endl;
	}else{
		cout<<k<<endl;
	}
}
}

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

int Sum_of_Prime(int n);
bool isPrime(int n);
int main()
{
	int N;
	while(cin>>N)
	{
		cout<<Sum_of_Prime(N)<<endl;
	}
	return 0;
} 
int Sum_of_Prime(int n)
{
	int p=1;
	if(n<2)
		return 0;
	for(int j=3;j<=n;j+=2)
	{
		if(isPrime(j))
			p++;
	}
	return p;
}

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

C++: #include<iostream>
using namespace std;
int main()
{
	int n,S;
while(cin>>n)
{
	S=0;
	if(n==1)
	{
		cout<<0<<endl;
	}
	if(n>=2)
	{
		S++;
	}
	for(int i=2;i<=n;i++)
	{
		for(int j=i-1;j>1;j--)
		{
			if(i%j==0)
			{
				break;
			}
			if(j==2)
		{
			S++;
		}
		}	
			
	}
	cout<<S<<endl;
}
return 0;
}

C++: #include <stdio.h>

const int MAX_V = 1000000;

int main() {
	int i, k, v;
	int prime[MAX_V + 1];
	int sum[MAX_V + 2];
	for (i = 2; i <= MAX_V; i++) {
		prime[i] = 1;
	}
	for (i = 2; i * i <= MAX_V; i++) {
		if (prime[i]) {
			for (k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0;
			}
		}
	}
	sum[1] = 0;
	sum[2] = 0;
	for (i = 2; i <= MAX_V; i++) {
		sum[i + 1] = sum[i] + prime[i];
	}
	while (scanf("%d", &v) != EOF) {
		printf("%d\n", sum[v + 1]);
	}
	return 0;
}

C++: #include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

const int N = 100000;

int main(void)
{
    bool a[N];
    int prime[N], n;
    rep(i,N+1)
    {
        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;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main() {
	int n;
	while (cin >> n){
		int sum = 0;
		if (n >= 2)sum++;
		for (int i = 3; i <= n; i += 2) {
			for (int j = 3; j <= sqrt(i); j += 2) {
				if (i%j == 0)goto x;
			}
			sum++;
		x:;
		}
		cout << sum << endl;
	}
	return 0;
}

C++: #coding:utf-8
import time
import math
import numpy as np

def flatten(L):
    if isinstance(L, list):
        if L == []:
            return []
        else:
            return flatten(L[0]) + flatten(L[1:])
    else:
        return [L]

def Eratos(data):

    p_list = [] # ????????????
    tmp = []
    num = int(math.sqrt(len(data)))+1
    for i in data:
        i=data[0]
        if i>num:
            break
        else:
            p_list.append(i)
            for j in data:
                if j%i == 0:
                    data.remove(j)
        
    p_list.append(data)
    return p_list

x = int(input())

r_list = list(range(2,(x+1)))
ans = []
ans = Eratos(r_list)

print("prime numbers is ")

print(len(flatten(ans)))

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

bool prime[MAX];

int countPrime(int n){
	if(n < 2) return 0;
	if(n == 2) return 1;

	int ret = 0;

	for(int i = 0; i < MAX; i++){
		prime[i] = true;
	}

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

int main(){
	int n;
	while(cin >> n){
		cout << countPrime(n) << endl;
	}
}

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

using namespace std;

int prime(int n);

int main(){
  vector<int> inp;
  int num,pri;					
  int i=0;

  while(cin>>num){
    if(num <= 1)inp.push_back(0);
    else{
      pri = prime(num);
      inp.push_back(pri);
    }
    i++;
  }
  int j = 0;
  while(j < i){
    cout<<inp[j]<<endl;
    j++;
  }
}

int prime(int num){
  int count=0;
  bool judge=0;
  for(int i = 2; i <= num; i++){
    judge =1;
    for(int j= 2; j < i; j++){
      if(i%j == 0)judge =0;
    }
    if(judge==1)count = count +1; 
  }
  return count;
}

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

int count_prime_number(int n){
	if(n < 2){
		return 0;
	}
	int count = 1;	//2??????
	for(int i = 3; i <= n; i += 2){
		int k = 0;
		for(int j = 3; j <= sqrt(i); j += 2){
			if(i % j == 0){
				k=1;
				break;
			}
		}
		if(k==0){
			count++;
		}
	}
	return count;
}

int main(){
	vector<int> results;
	int in_num;
	while(cin >> in_num){
		results.push_back(count_prime_number(in_num));
	}
	for(auto result : results){
		cout << result << endl;
	}
	return 0;
}

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

void count_Prime(int n);
int IsPrime(int num);


int main()
{
	int Data = 0;

	cin >> Data;
//	while (cin >> Data)
		count_Prime(Data);

	return 0;
}

void count_Prime(int n)
{
	int counter = 1,  i = 0;
	for (i = 2; i < n; ++i)
		counter += IsPrime(i);		

	cout << counter << endl;

}

int IsPrime(int num)
{
	if (num < 2) return 0;
	else if (num == 2) return 1;
	else if (num % 2 == 0) return 0; // ??¶??°????????????????????????

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// ?´???°??§?????????
			return 0;
		}
	}

	// ?´???°??§??????
	return 1;
}

C++: #include<stdio.h>
#define max 1000001

int main(void)
{
	int *d, f1, f2, n, cnt;
	d = new int [max];
	for(f1 = 0; f1 < max; f1++)
	{
		d[f1] = 1;
	}
	for(f1 = 2; f1 *f1 < max; f1++)
	{
		if(d[f1] == 1)
		{
			for(f2 = 2 * f1; f2 < max; f2 += f1)
			{
				d[f2] = 0;
			}
		}
	}
	while (scanf("%d",&n) != EOF)
	{
		cnt=  0;
		for(f1 = 2; f1 <= n; f1++)
		{
			if(d[f1] == 1)
				cnt++;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
bool prime[1000000];
void sieve() {
    fill_n(prime, 1000000, true);
    prime[0] = false;
    prime[1] = false;
    for (int i=2; i<=1000; ++i) {
        if (prime[i]) {
            for (int j=i*i; j<1000000; j+=i) {
                prime[j] = false;
            }
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    sieve();

    int memo[1000000];
    for (int i=1; i<1000000; ++i) {
        memo[i] = memo[i-1]; 
        if (prime[i]) {
            memo[i] ++; 
        }
    }

    int n;
    while (cin >> n) {
        cout << memo[n] << "\n";
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int n;
#define MAX_N 999999

int prime[MAX_N]; // i番目の素数
bool is_prime[MAX_N + 1]; // is_prime[i]がtrueならiは素数

// n以下の素数の数を返す
int sieve(int n) {
    int p = 0;
    for(int i=0;i<=n;i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for (int i=2; i<=n; i++) {
        if (is_prime[i]) {
            prime[p++] = i;
            for(int j=2*i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return p;
}

main() {
    sieve(MAX_N);
    cin>>n;
    int ans=0;
    for(int i=2;i<=n;i++) {
        if(is_prime[i]) ans++;
    }
    cout << ans << endl;
}