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 <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}

vector<bool> IsPrime;

ll sieve(ll max){
    ll sum=0;
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    }
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(ll i=2; i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) {
            sum++;
            for(size_t j=2; i*j<=max; ++j) IsPrime[i*j] = false;
        }
    return sum;
}



ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(scanf("%d",&n)!=EOF){
        cout<<sieve(n)<<endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int i,j,flag,n,c=0;
    while(scanf("%d",&n)==1)
    {
        for(i=2;i<=n;i++)
        {
            flag=0;
            for(j=2;j<=sqrt(i);j++)
            {
                if(i%j==0)
                {
                    flag=1;
                }
            }
            if(flag==0)
            {
                c++;
            }
        }
        printf("%d\n",c);
        c=0;
    }
    return 0;
}

C++: #include <stdio.h>
const int MAX_V = 999999;
int main(){
int prime[MAX_V+1]={0};
int sum[MAX_V+2]={0};
int i, k, v ,n;
  for(i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++) {
    if(prime[i]) {
      for(k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }
  for(i=0 ;i<=MAX_V+1 ;i++){
    sum[i+1] += sum[i] + prime[i];
  }

  while(scanf("%d" ,&n)!=EOF){
     printf("%d\n" ,sum[n+1]);
  }
  return 0;
}

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

bool prime[1000001];

void era(){
	for(int i=2;i<1000000;i++)prime[i]=true;
	for(int i=2;i*i<1000000;i++){
		if(prime[i]==true){
			for(int j=i*2;j<1000000;j+=i){
				prime[j]=0;
			}
		}
	}
}

int main(){
	era();
	int n,ans;
	while(cin>>n){
		ans=0;
		for(int i=0;i<=n;i++){
			if(prime[i]==1)ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

typedef unsigned int U;

const U R = 1000000;
bool isp[R];
vector<U> primes;

void elatos(){
  memset(isp , 1 , sizeof(isp));
  U n = 0;
  for(U i=2; i < R; i++)
    if(isp[i])
      for(U j=2*i; j < R; j+=i) isp[j] = 0;
  for(U i=2; i<R; i++) if(isp[i]) primes.push_back(i);
}

int main(){
  elatos();
  int n;
  while(cin >> n){
    vector<U>::iterator it = upper_bound(primes.begin(), primes.end() , n);
    cout << it - primes.begin() << 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*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;i++){
			if(data[i]==1)j++;
		}
		printf("%d\n",j);
	
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#ifndef typeof
#define typeof __typeof__
#endif // typeof

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(typeof((c).rbegin()) i = (c).rbegin(); i != (c).rend(); i++)
#define repby(i, a, b, step) for(typeof(b) i = (a); i < (b); i += (step))
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

vector<bool> prime_table;
vi nprimes;

void mkprime_table(int n) {
  prime_table = vector<bool>(n+1, true);
  nprimes = vi(n+1, 0);
  prime_table[0] = prime_table[1] = false;
  for (int i = 4; i <= n; i += 2) {
    prime_table[i] = false;
  }

  for (int i = 3; i*i <= n; i += 2) {
    if (prime_table[i]) {
      for (int j = 2; i*j <= n; j++) {
        prime_table[i*j] = false;
      }
    }
  }

  int total = 0;
  for (int i = 0; i <= n; i++) {
    if (prime_table[i]) {
      total++;
    }
    nprimes[i] = total;
  }
}

int main(int argc, char **argv)
{
  vi v;
  int n;

  while (cin >> n) {
    v.pb(n);
  }

  mkprime_table(*max_element(all(v)));

  tr(v, i) {
    cout << nprimes[*i] << endl;
  }

  return 0;
}

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

int main(){
  int input;
  scanf("%d",&input);
  int count = 1;
  for(int i = 3;i <= input;i += 2){
    bool isPrime = false;
    for(int s = 3;s <= sqrt((float)i);s += 2){
      if(i % s == 0){isPrime = true; break;}
    }
    if(!isPrime)count++;
  }
  printf("%d\n",count);


  return 0;
}