Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [100]int
	var inputCount, primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		resultArr[inputCount] = primeCount
		if inputCount == 30 {
			break
		}
		primeCount = 0
		inputCount++
	}
	for _, v := range resultArr {
		fmt.Printf("%d\n", v)
	}
}

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

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

#define MAXINT 1000000
bool isprime[MAXINT];
ll int sum[MAXINT];
void makeprime(){
	REP(i,MAXINT) isprime[i] = true;
	FOR(i,2,sqrt(MAXINT)+1){
		FOR(j,i+1,MAXINT-1){
			if(j%i==0) isprime[j] = false;
		}
	}
}

int main(){
	makeprime();
	sum[0] = 0;
	sum[1] = 0;
	sum[2] = 1;
	FOR(i,3,MAXINT){
		if(isprime[i]) sum[i] = sum[i-1]+1;
		else sum[i] = sum[i-1];
	}
	ll int n;
	while(cin >> n){
		cout << sum[n] << endl;
	}
}

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

int main() {
	int n, t = 0;
	cin >> n;
	for(int i = 1;i < n + 1;++i){
	   for(int j = 2;j < i;++j){
	   	if(i / j == 0) break;
	   	if(j == i - 1) t++;
	   }	
	}
	cout << t << endl;
	return 0;
}

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

C++: #include<iostream>
using namespace std;
bool arr[1000000];
int main()
{
	int n,p;
	cin>>n;
  	for(int i=2;i<=1000000;i++){
		if(arr[i]==0)
		{
		    p=i;
			for (int j=2;p*j<=1000000;j++)
			{
				arr[p*j]=1;
			}
		}
	}
	int count=0;
	for(int i=2;i<=n;i++){if(arr[i]==0)count++;}
	cout<<count<<endl;
	delete[] arr;
	return 0;
}

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

using  namespace std;

typedef long long ll;

int iprime[999999];
bool is_prime[1000000];

int prime(int n)
{
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;
	int p = 0;
	for(int i = 2; i <= n; ++i)
	{
		if(is_prime[i])
		{
			iprime[p++] = i;
			for(int j = 2*i; j <= n; j += i)
				is_prime[j] = false;
		}
	}
	return p;
}

int main()
{
	int n;
	while(true)
	{
		if(scanf("%d", &n) == EOF)
			break;
			
		printf("%d\n", prime(n));
	}
}

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

using namespace std;

int main()
{
	int n;

	while (cin >> n){
		int pn = 0;
		for (int i = 2; i <= n; i++){
			bool flag = true;
			for (int j = 2; j <= n; j++){
				if (i % j == 0 && i != j){
					flag = false;
					break;
				}
			}
			if (flag) pn++;
		}
		
		cout << pn << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>
#include <sstream>

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================
vector<int>prime(1000000);
vector<bool>is_prime(1000001);

//Sieve of Eratosthenes
int func(int N) {
	int p = 0;

	REP(i, N + 1) is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;

	REP2(i, 2, N + 1) {
		if (is_prime[i]) {
			prime[p++];
			for (int j = 2 * i; j <= N; j += i) is_prime[j] = false;
		}
	}
	return p;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int N;
	while (cin >> N) {
		cout << func(N) << "\n";
	}
	return 0;
}

C++: #include<iostream>

int main(){
    int n, count = 0;
    bool isprime [1000000];
    for(int i = 0; i < 1000000; i++)
        isprime[i] = true;
    isprime[0] = isprime[1] = false;
    for(int i = 2; i <= 1000; i++){
        if(isprime[i]){
            for(int j = i * 2; j < 1000000; j += i){
                isprime[j] = false;
            }
        }
    }
    while(std::cin >> n){
        count = 0;
        for(int i = 2; i <= n; i++){
            if(isprime[i])
                count++;
        }
        std::cout << count << std::endl;
    }
}

C++: #include <cstdlib>
#include <iostream>
#include <math.h>



void Eratosthenes(int N){

}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);

    int n,m;
    while (std::cin >> n) {
        // std::cout << n << "," << std::endl;
        m = 0;
        int arr[n];
        for(int i = 0; i <= n; i++){
            arr[i] = 1;
        }
        for(int i = 2; i <= sqrt(n); i++){
            if(arr[i]){
                for(int j = 0; i * (j + 2) <= n; j++){
                    arr[i *(j + 2)] = 0;
                }
            }
        }
        for(int i = 2; i <= n; i++){
            if(arr[i]){
                // std::cout << i << std::endl;
                m++;
            }
        }
        std::cout << m << std::endl;
    }
    return EXIT_SUCCESS;
}

C++: #include <iostream>
#include <cmath>
#define N 1000000

bool m[N];

void init_array() {
    int n = N-1;
    int idx = 2;
    std::fill(m, m+N, true);
    while (idx <= sqrt(n)) {
        int next_itr = -1;
        for (int i=idx+1; i<=n; i++) {
            if (m[i]) {
                if (i % idx == 0) {
                    m[i] = false;
                } else if (next_itr == -1) {
                    next_itr = i;
                }
            }
        }
        idx = next_itr;
    }
}

int main(void) {
    int n;
    int res;
    init_array();
    while( std::cin >> n ) {
        int idx = 2;
        int res=0;

        for (int i=2; i<=n; i++) {
            if (m[i]) res++;
        }

        std::cout << res << std::endl;
    }

    return 0;
}

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

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

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

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