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>
using namespace std;

#define Max 1000000

int isPrime[Max];

int main(){
    int num;
    int i;

    isPrime[0] = isPrime[1] = 0;
    for(i = 2; i < Max; ++i){
        isPrime[i] = 1;
    }
    
    for(i = 3; i < Max; ++i){
        if(i % 2 == 0){
            isPrime[i] = 0;
        }
    }

    for(i = 4; i < Max; ++i){
        if(i % 3 == 0){
            isPrime[i] = 0;
        }
    }

    for(i = 6; i < Max; ++i){
        if(i % 5 == 0){
            isPrime[i] = 0;
        }
    }

    for(i = 8; i < Max; ++i){
        if(i % 7 == 0){
            isPrime[i] = 0;
        }
    }

    while(cin >> num){
        int count = 0;
        for(i = 0; i <= num; ++i){
            if(isPrime[i] == 1){
                count++;
            }
        }
        cout << count << endl;
    }
}

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

int main(){
    vector<int> prime;
    int n;
    for(int i=2;i<1000000;i++){
        bool isprime=true;
        for(int j=2;j<=sqrt(i);j++){
            if(i%j==0){
                isprime=false;
                break;
            }
        }
        if(isprime) prime.push_back(i);
    }
    while(cin >> n){
        for(int i=0;i<prime.size();i++){
            if(prime[i]>n){
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

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

int main(){
	int n;
	bool num[MAX_N];
	for(int i=0;i<MAX_N;i++) num[i]=false; 

	while(cin>>n){
		int ans=0;
		for(int i=2;i<=n;i++){
			if(num[i]) continue;
			for(int j=2;j<=n/i;j++) num[i*j]=true;
			ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

int prime[10000];
bool is_prime[1000000];

int sosuu(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=i*2; j<=n; j+=i) {
                is_prime[j]=false;
            }
        }
    }
    return p;
}

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

C++: #include<iostream>
using namespace std;
int PrimeNum(int n){
  for(int i = 2;i <= n;i++){
    if(i == n){
      return 1;
    }
    if(n % i == 0){
      return 0;
    }
  }
}
int main(){
  int n,num;
  for(cin >> n;n != 0;cin >> n){
    num = 0;
     for(int k = 2;k <= n;k++){
       if(PrimeNum(k) == 1){
	 num = num +1;
       } 
     }
     cout << num;
  }
}

C++: #include <iostream>
#include <cmath>
using namespace std;
bool whether(int num);
int count(int num);

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

bool whether(int num){//if num is prime, 1
    int s=sqrt(num);
    for(int i=3; i<=s; i+=2){
        if(num%i==0){ return 0; }
    }
    return 1;
}

int count(int num){
    int a=1;
    if(num<=2){ return num-1; }
    for(int i=3; i<=num; i+=2){
        if(whether(i)){ a+=1; }
    }
    return a;
}

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

int main(void){
  int n;
  while(cin >> n){
    if(n < 3){
      if(n < 2){
	cout << 0 << endl;
      }else{
	cout << 1 << endl;
      }
    }
    int ans = 0;
    for(int i = 3; i <= n; i += 2){
      bool flag = true;
      for(int j = 3; j <= sqrt(i); j += 2){
	if(i % j == 0){
	  flag = false;
	}
      }
      if(flag)
	ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	long long int N,count[1000000];
		count[1] = 1;
	for(int x=2;x<=1000000;x++){
		int flag = 0;
		for(int y=2;y<x;y++){
			if((x%y)==0)	flag = 1;
		}
		if(flag == 0)	count[i] = count[i-1]+1;
	}
	while(cin >> N){
		cout << count[N] << endl;
	}
	return 0;
}

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

int main(void) {
    int n;
    while(cin >> n) {
        int a[n];
        for(int i = 0; i <= n; i++) {
            a[i] = 1;
        }
        for(int i = 2; i <= sqrt(n); i++) {
            if(a[i]) {
                for(int j = 2; i * j <= n; j++) {
                    a[i * j] = 0;
                }
            }
        }
        int cnt = 0;
        for(int i = 2; i <= n; i++)
            if (a[i]) cnt++;
        cout << cnt << endl;
    }
}

C++: #include<iostream>
#include<stdlib.h>
main(){
	int i,j,n;//,p[1000000];
	std::cin>>n;

	int *p=(int *)malloc(8000000);
	for(i=2;i<=n;i++)
		p[i]=1;
	for(i=2;i<n;i++)
		for(j=2;i*j<=n;j++)
			p[i*j]=0;
	j=0;
	for(i=2;i<=n;i++)
		j+=p[i];
	std::cout<<j<<std::endl;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n, cnt;
	bool prime[1000000] = {false};
	prime[1] = true; //1???????????\	
	
	while(cin >> n){	
		// ??¨??????????????????????????????
		for(int j = 2; j*j <= n; j++){
			if(prime[j] == false){
				for(int k = j; k*j <= n; k++){
					prime[j*k] =true;
				}
			}
		}
		cnt = 0;
		for(int i = 1; i <= n; i++){
			if(prime[i] == false) cnt++;
		}
		
		cout << cnt << endl;
	}
}

C++: #include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    while(cin >> n) {
        int ans = 1;
        
        for(int i = 3; i <= n; i+=2) {
            bool isPrime = true;
            for(int j = 3; (j * j) <= i; j+=2) {
                if(i % j == 0) {
                    isPrime = false;
                    break;
                }
            }
            if(isPrime) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

C++: 
#include <iostream>
#include <stdlib.h>
using namespace std;
#define thefor(i,end) for (i=0;i<end;i++)
int main()
{    
	int n,con,a,i,j;
	while(cin>>n)
	{
		con=1;
		for (i=3;i<=n;i++)
		{
			for (j=2;j<i;j++)
			{
				if (i%j==0)
				{
					break;
				}
			}
			if (j==i)
			{
				con++;
			}
		}
		cout<<con<<endl;
	}
	
}

C++: #include <bits/stdc++.h>

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;

inline int Sieve_of_Eratothenes(const int n) {

	std::vector<bool> flg(n + 1, true);
	for (int i = 2; i*i <= n; i++) {
		if (flg[i]) {
			for (int j = i + i; j <= n; j += i) {
				flg[j] = false;
			}
		}
	}

	return(std::count(flg.begin(), flg.end(), true) - 2);

}

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int a = 0;
	std::vector<int> A;
	while (std::cin >> a) {
		A.push_back(a);
	}

	std::for_each(A.begin(), A.end(),
		[](int i) {std::cout << Sieve_of_Eratothenes(i) << std::endl; });
}

C++: #include<iostream>
#include<cmath>
using namespace std;
bool isprime(int n) {
	if (n == 2)return true;
	for (int i = 3; i <= sqrt(n); i += 2) if (n%i == 0)return false;
	return true;
}
int main() {
	long long n; while(cin >> n){
		long long sum;
		if (n == 1)sum = 0;
		else {
			sum = 1;
			for (int i = 3; i < n + 1; i += 2) {
				if (isprime(i))sum++;
			}
		}
		cout << sum << '\n';
	}
	return 0;
}