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 <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

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

int main() {
   vector<int> v(1000000,0),rui(1000000,0);
   rep(i,1,999999)if(isPrime(i))v[i]=1;
   rui[0]=v[0];
   rep(i,1,999999)rui[i]=rui[i-1]+v[i];
   
   int n;
   while(cin>>n){
       cout<<rui[n]<<endl;
   }
   
    
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >> n){
    int ans=0,math[1000001]={0};
    math[1]=1;
    for(int i=2;i<n+1;i++){
      int bell=i;
      if(math[i]==0){
	ans++;
	math[i]=1;
      }
      while(bell<=n){
	bell+=i;
	if(math[bell]==0){
	  math[bell]=1;
	}
      } 
    }
    cout << ans << endl;
  }
}

C++: #include<stdio.h>
#include<math.h>

int sos(int);

int pri[10000000];

int main(){
  int x;
  while(scanf("%d",&x)!=EOF){
    printf("%d\n",sos(x));
  }  
  return 0;
}

int sos(int a){
  int i,j,c=0,b;
  for(j=2;j<=a;j++){
    b=0;
    if(pri[j]==3)continue;
    if(pri[j]==1){c++;continue;}
    for(i=2;i<=sqrt(j);i++){
      if(j%i==0){pri[j]=3;b=1;break;}
      
    }
    if(b==0){pri[j]=1;c++;}
  }
  return c;
}

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

using namespace std;

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

	return true;
}

int main()
{
	int N;

	static int C;

	cin >> N;

	for (int i = 2; i <= N; i++)
	{
		if (isprime(i) == true)
		{
			C += 1;
		}
	}

	cout << C << endl;

	return 0;
}

C++: #include<iostream>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
const int M = (1e6);
bool p[M];
long long int cnt[M];
void isPrime(){
  rep(i,M)p[i] = true;
  p[0] = p[1] = false;
  cnt[0] = cnt[1] = 0;
  loop(i,2,M){
    cnt[i] = cnt[i-1] + p[i];
    if(p[i])
      for(int j = i + i ; j < M ; j += i)
	p[j] = false;
  }
  rep(i,10)cout<<cnt[i]<<endl;
}
int main(void){
  isPrime();
  int n;
  while(cin>>n)cout<<cnt[n]<<endl;
}

C++: #include <cctype>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define LL long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

vector<int> vec;

void makesosuu(void){
	FOR(i, 2, 999999){
		if(i == 2){
			vec.pb(i);
		}else if(i % 2 != 0){
			bool flag = true;
			int j = 3;
			while(j * j <= i){
				if(i % j == 0){
					flag = false;
					break;
				}
				j += 2;
			}
			if(flag) vec.pb(i);
		}
	}
	return;
}

int sosuu(int n){
	int i = 0;
	while(vec[i] < n && i < vec.size()) ++i;

	return i;
}

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

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

int prime[MAX_N];
bool is_prime[MAX_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;
}

int main()
{
	int s;
	while( cin >> s )
	{
		cout << sieve(s) << endl;
	}
	
		
	return 0;	
}

C++: //Prime Number
#include<iostream>
#include<cstdio>

using namespace std;

int main() {
	int n;
	while(cin >> n) {
		int count = 0;
		for(int i = 2; i <= n; i++) {
			bool flag = true;
			for(int j = 2; j <= i/2; j++) {
				if(i % j == 0) {
					flag = false;
					break;
				}
			}
			if(flag == true) {
				count++;
			}
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#include <assert.h>
#include <random>

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14


using namespace std;

// nまでの素数のリストを作成(nを含む) O(N log long N)
vector<int> make_prime_list(int n) {
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;

    vector<int> prime_list;
    for (int i = 2; i < n + 1; ++i) {
        if (!is_prime[i]) { continue; }
        prime_list.emplace_back(i);

        for (int j = i; j < n + 1; j += i) {
            is_prime[j] = false;
        }
    }
    return prime_list;
}

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    vector<int> prime_list = make_prime_list(1000001);

    int n;
    while(cin >> n) {
        int ans = 0;
        for(int i=0;;++i)  {
            if(prime_list[i] <= n){
                ans++;
            }
            else {
                break;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

C++: #include<iostream>

using namespace std;

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

int main(void)
{
	int n;
	bool flag[1000000];
	for(int i=1;i<=999999;i++){
		flag[i]=sosu(i);
	}
	while(cin>>n){
		int ans=0;
		for(int i=2;i<=n;i++){
			if(flag[i])
				ans++;
		}
		cout<<ans<<endl;
	}
}