Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		input := nextInt()
		fmt.Println(IsPrime(input))
	}
}

func IsPrime(num int) int {
	eratos := make([]bool, num+1)
	c := 0
	for i := 2; i < len(eratos); i++ {
		if eratos[i] == false {
			c++
			eratosCalc(i, eratos)
		}
	}
	return c
}

func eratosCalc(primeNum int, eratos []bool) {
	for i := primeNum * primeNum; i < len(eratos); i += primeNum {
		eratos[i] = true
	}
}

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

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

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

int main() {
	// your code goes here
	int nu[30];
	int num;
	int count = 0;
	int max = 29;
	for(int x=0;x<30;x++){
		nu [x] = -1;
		cin >> nu[x];
		if (nu[x] == -1) {
			max = x;
			break;
		}
	}
	for (int y=0;y<max;y++) {
		num = nu[y];
		count = 0;
		
		for (int i = 1;i<=num;i++) {
		if(i%2==0) {
			//cout <<"2: "<<i<<endl;
			count ++;
			continue;
		}
		if(i==5||i==7) continue;
		for (int j=9;j<(int)sqrt(i)+1;j=j+2) {
			if (i%j==0) {
				count ++;
				//cout <<"i: "<<i<<" j: "<<j<<endl;
				break;
			}
		}
	}
	cout << (num-count) <<endl;
	//cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int prime(int);
int main(){
    int a,sum;
    int b[999999];
    b[0]=0;
    for(int i=1;i<999999;i++){
        b[i]=prime(i);
    }
    while ( cin >> a){
        sum =0;
        for (int i=0;i<a;i++){
            sum +=b[i];
        }
        cout << sum-1 << endl;
    }
}


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

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
int p(long x)
{
    long i,j=sqrt(x),k=1;
    for(i=2;i<=(j);i++)
    {
        if(x%i==0){
            k=0;
            //return k;
        break;

        }
    }
    if(k==1)return 1;
    else return 2;
}
using namespace std;
int main()
{
    double a,b,c,i,n,s=0;
    i=1;

    while(i){
        if(i>=30)break;
        cin>>n;
        s=0;
    //a=sqrt(n);
    for(i=2;i<=n;i++)
    {
        if(p(i)==1){s++;}
    }
    cout<<s<<endl;
    i++;
    }


    return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>

using namespace std;

int n, ct = 0;
bool p[1000001];

int main(){
	for (int i = 0; i < 1000001; i++) p[i] = 1;
	for (int i = 2; i < 1000; i++){
		if (p[i] == 1){
			for (int j = 0; i*(j + 2) < 1000000; j++){
				p[i*(j + 2)] = 0;
			}
		}
	}
	while (cin >> n){
		for (int i = 2; i < n + 1; i++)
			if (p[i] == 1) ct++;
		cout << ct << endl;
		ct = 0;
	}
}

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

int main(){
    vector<int> ns;
    int temp, max_n = 0;
    while(cin >> temp){
        ns.push_back(temp);
        max_n = max(temp, max_n);
    }
    max_n++;

    vector<bool> is_prime(max_n, true);
    vector<int> primes;
    for(ll i=2;i<max_n;i++){
        if(is_prime[i]){
            primes.push_back(i);
            for(ll j=i*i;j<max_n;j+=i){
                is_prime[j] = false;
            }
        }
    }

    for(int n: ns){
        int ans = upper_bound(primes.begin(), primes.end(), n) - primes.begin();
        cout << ans << endl;
    }

    return 0;
}

C++: #include<stdio.h>


int main(){
	int n;
	bool data[1000000];

	int i,j;
	data[0]=data[1]=0;
	for(i=2;i<1000000;i++){
		data[i]=1;
	}

	for(i=0;i<1000000;i++){
		if(data[i]==1){
			for(j=i+i;j<1000000;j=j+i){
				data[j]=0;
			}
		}
	}


	while(scanf("%d",&n)!=EOF){
		j=0;
		for(i=0;i<n+1;i++){
			if(data[i]==1)j++;
		}
		printf("%d\n",j);
	
	}
	return 0;
}

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

int is_it_primeNum(int n)
{
	int a = 1;
	if (n == 0 || n == 1)
		return 0;
	else if (n == 2)
		return 1;
	else if(n % 2 == 0)
		return 0;
	else{ 
		for(int i=3;i<n/2;i+=2){
			if (n%i==0){
				a = 0;
				break;}
		}
	}
	return a;
}
int how_much_primeNum(int n)
{
	int ans = 0;
	for(int i=2;i<=n;i++){
		ans += is_it_primeNum(i);
	}
	return ans;
}

int main()
{
	int n;
	while(cin>>n)
		cout << how_much_primeNum(n) << endl;
	return 0;
}

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

int main() {
	int n;
	int cnt = 0;
	while(cin >> n) {
		cnt++;
	}
	if(cnt > 1000)
		abort();
}

C++: #include <iostream>
#include <map>
using namespace std;
#define MAX_N 999999
int main()
{
    int n;
    map<int,bool>notPrime;
    map<int,int>count;
    for (int i = 2 ; i <= MAX_N ; i++)
    {
        if (!notPrime[i])
        {
            for (int g = i+i ; g <= MAX_N ; g += i)
            {
                notPrime[g] = true;
            }
        }
    }
    int cnt = 0;
    count[1] = 0;
    for (int g = 2 ; g <= MAX_N ; g++)
    {
        if (!notPrime[g])
            cnt ++;
        count[g] = cnt;
    }
    while (cin >> n)
    {
        cout << count[n] << endl;
    }
    
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
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)){
         if (x%i==0)return false;
        i= i+2;
    }
    return true;
}
int main(){
    int in[30]={};
    int out=0;
	int max=0;
	bool flag[100000];
    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;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];j++){
			 if(flag[j]==true){
				 out++;
			 }
		}
       cout <<out <<endl;
    }
     
    return 0;
}

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

int CountPrime(int N);
int CheckPrime(int N);
bool IsPrime(int num);

int main()
{
	int N;

	while (std::cin >> N)
	{
		std::cout << CountPrime(N) << std::endl;
	}
}

int CountPrime(int N)
{
	int Counter = 0;

	for (int i = 1; i <= N; i++)
	{
		Counter += CheckPrime(i);
	}

	return Counter;
}

int CheckPrime(int N)
{
	if (IsPrime(N))
		return 1;

	return 0;
}

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num == 3) return true;
	else if (num % 2 == 0) return false; // ??¶??°????????????????????????
	else if (num % 3 == 0) return false; // 3????????°????????????????????????


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

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

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

bool isprime(int number, const std::vector<int>& primeset)
{
	for (std::vector<int>::const_iterator p = primeset.begin(); p != primeset.end(); ++p) {
		if (number % *p == 0) {
			return false;
		}
	}
	return true;
}

int resolve(int number)
{
	std::vector<int> primeset;
	int checkmax = static_cast<int>(std::sqrt(static_cast<float>(number)));
	for (int i = 2; i <= checkmax; ++i) {
		if (isprime(i, primeset)) {
			primeset.push_back(i);
		}
	}
	if (isprime(number, primeset)) {
		primeset.push_back(number);
	}
	return static_cast<int>(primeset.size());
}

int main()
{
	int input;
	while (std::cin >> input) {
		std::cout << resolve(input) << std::endl;
	}

	return 0;
}