Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2 || num == 5:
		return true
	case num < 2 || num%2 == 0 || num%5 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
 
 
// cin >>
// cin <<
bool isPrime(int x){
    if(x==2) return true;
    if(x<2||x%2==0) return false;
    int i=3;
    while(i<=sqrt(x*1.0)){
         if (x%i==0)return false;
        i= i+2;
    }
    return true;
}
int main(){
    int in[30]={};
    int out=0;
	int max=0;
	bool flag[1000002];
    for(int i=0;i<30;i++){
		cin >>in[i];
		if(i==0){
			max=in[i];
		}else{
			if(in[i]>max){
				max=in[i];
			}
		}
	}
	for(int j=0;j<max+1;j++){
		if(isPrime(j)==true){
			flag[j]=true;
		}else{
			flag[j]=false;
		}
    }
	
    for(int i=0;i<30;i++){
		out=0;
		for(int j=0;j<in[i]+1;j++){
			 if(flag[j]==true){  
				 out++;
			 }
		}
		if(out!=0){
		 cout <<out <<endl;
		}
    }
     
    return 0;
}

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

int a[1000000];

int main()
{
  int n;
  int count;

  for (int i = 2; i < 1000000; i++){
    a[i] = 1;
  }

  for (int i = 0; i * i < 1000000; i++){
    if  (a[i] == 1){
      for (int j = 2; j * i <= 100000; j++){
        a[j * i] = 0;
      }
    }
  }

  while (cin >> n){
    count = 0;
    for (int i = 0; i < 1000000; i++){
      if (a[i] == 1){
        count++;
      }
    }
  }

  cout << count << endl;

  return (1);
}

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

int main(){
	int n;
	int count;
	int ans;

	while (cin >> n){
		ans = 0;
		for (int i = 2; i <= n; i++){
			count = 0;
			for (int j = 2; j < i; j++){
				if (i % j == 0){
					count++;
				}
			}
			if (count == 0)ans++;
		}
		cout << ans << endl;

	}


	return 0;
}

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

int main(){
	
	int i, j, num;
	int* pT;
	
	while(cin>>num){
		int count=0;
		pT = new int[num];
		
		for(i=0; i<num; i++){
			pT[i] = 0;
		}
		
		pT[0] = 1;
		
		for(i=2; i<=(num/2); i++){
			for(j=2; i*j<=num; j++){
				if(pT[i*j-1]==0){
					pT[i*j-1] = 1;
				}
			}
		}
		
		for(i=0; i<num; i++){
			if(pT[i]==0){
				++count;
			}
		}
		
		delete[] pT;
		
		cout << count << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int prime(int);
int main(){
    int a,n;
    while ( cin >> a){
        n=0;
        for (int i=2;i<a;i++){
            if (prime(i)==0){
                n++;
            }
        }
        cout << n << endl;
    }
}


int prime(int x){
    if(x==2 || x==3 || x==5 || x==7)
        return 0;
    if(x%2==0)
        return 1;
    if(x%3==0)
        return 1;
    for (int i=5;i<=sqrt(x)+1;i+=6){
        if(x%i==0 || x%(i+2)==0)
            return 1;
    }
    return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int primes[999999];
bool marks[999999+2];

int sive(int n)
{
    int i,limit=sqrt(n)+1,j,total,x=0;

    for(i=1;i<=n;i++)
        marks[i]=1;
    marks[0]=0;


    for(i=2;i<=limit;i++)
    {
        for(j=i;j*i<=n;j++)
            marks[i*j]=0;
    }
    for(i=0;i<=n;i++)
    if(marks[i]==1)
        x++;
    return x;
}
int main()
{
    long long n;
    for(int i=1;i<=30;i++){
    cin>>n;

    cout<<sive(n)-1<<endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    bool is_prime[1000000];

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

    for(int i=2; i*i<1000000; i++){
        if(is_prime[i]){
            for(int j=i*i; j<1000000; j+=i){
                is_prime[j] = false;
            }
        }
    }
    int n_prime[1000000];
    int cnt = 0;
    for(int i=0; i<1000000; i++){
        if(is_prime[i]){
            cnt++;
        }
        n_prime[i] = cnt;
    }
    while(true){
        int n;
        cin >> n;
        if(cin.eof())
            break;
        cout << n_prime[n] << endl;
    }
    return 0;
}

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

int main() {
	int n;
	while(cin >> n) {
		vector<int> a(n, 1);
		a[0] = 0;

		for(int i=1; i<(int)sqrt(n); i++) {
			if(a[i] == 1) {
				for(int j=i+1; (i+1)*j<=n; j++) { // 素数の倍数のフラグを消していく
					a[(i+1)*j-1] = 0;
				}
			}
		}

		int ans = 0;
		for(int i = 0; i<n; i++) {
			if(a[i] == 1) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <math.h>
#define MAX 80000
using namespace std;

int main(){
	int n;
	int prime[MAX],i,j;
	int count;
	bool flag;

	while((cin >> n)!= NULL){
		count = 0;
		for(i = 3; i <= n; i+=2){
			flag = true;
			for(j = 0; j < count; j++){
				if(i % prime[j] == 0){
					flag = false;
					break;
				}
			}
			if(flag == true){
				prime[count++] = i;
			}
		}
		if(n > 1)	count++; //2
		cout << count << endl;
		//delete[] prime;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int ans[999999];

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

int main() {
    FOR(i, 1, 999999) {
        ans[i] = ans[i-1] + isprime(i+1);
    }
    int i;
    while(cin >> i) {
        cout << ans[i-1] << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;
int sieve(int n);
int prime[1000000];
bool is_prime[1000000];

int main()
{

	int p = 0;
	for (int i = 0; i <= 999999; i++) {
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= 999999; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= 999999; j += i) {
				is_prime[j] = false;
			}
		}
	}
	int n;
	while (scanf_s("%d", &n) != EOF) {
		int i = 0;
		while (prime[i] <= n) {
			i++;
		}
		cout << i << endl;
	}
}

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

int main(){
	char nums[1000000];
	int n;
	for(int i = 2; i < 1000000; i++)
		nums[i] = 1;
	for(int j = 2; j < 1000; j++)

		for(int k = 2; j * k <= 1000000; k++)
			nums[j * k] = 0;
	while(cin >> n){
		int count = 0;
		for(int l = 2; l <= n; l++)
			if(nums[l])
				count++;
		cout << count << endl;
	}
	return 0;
}

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

int main()
{
	bool isPrime[1000000];
	int num[1000000];
	memset(isPrime,false,sizeof(isPrime));
	isPrime[0]=isPrime[1]=true;
	for (int i = 2; i < 1000000; i++) {
		if(isPrime[i])
		{
			num[i]=num[i-1];
			continue;
		}

		for(int j=i*2;j<1000000;j+=i)
		{
			isPrime[j]=true;
		}
		num[i]=num[i-1]+1;
	}

	int n;
	while(cin>>n) cout<<num[n]<<endl;
	return 0;
}

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

bool isprime(int x) {
	if (x == 2)
		return true;
	if ((x < 2) || (x % 2 == 0)) {
		return false;
	}
	int i = 3;
	while (i == sqrt(x)) {
		if (x%i == 0)
			return false;
		i = i + 2;
	}
	return true;
}

int main()
{
	
	int n;
	while (cin >> n) {
		int C = 0;
		for (int i = 0; i <= n; i++) {
			if (isprime(i) == true)
				C++;
		}
		cout << C<<endl;
	}
	return 0;
}