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;
int main(){
	int a,n,i,j;
	for(int l=0;l<2;l++){
	cin>>a;
	n=0;
	for(i=2;i<=a;i++){
		for(j=2;j<i;j++){
			if(i%j==0)break;
		}
		if(i == j) n += 1;
	}
	cout<<n<<endl;
	}
}

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

bool is_prime(std::vector<int> &primes, int n){
	bool ret = true;
	int max_i = sqrt(n);

	for(int i = 0; i < primes.size(); i++){
		if(primes[i] > max_i){break;}
		if(n % primes[i] == 0){
			ret = false;
			break;
		}
	}
	return ret;
}

int main(int argc, char **argv){
	int n = 0;
	std::vector<int> primes;

	primes.push_back(2);

	while(std::cin >> n){
		int num_primes = 1;
		for(int i = 3; i <= n; i += 2){
			if(is_prime(primes, i)){
				num_primes++;
				if(i > primes.back()){
					primes.push_back(i);
				}
			}
		}

		std::cout << num_primes << std::endl;
	}
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

inline bool IN(int x, int y, int w, int h)
{
    return 0 <= x && x < w && 0 <= y && y < h;
}


int main()
{
	int n;
	vi pn(1000000,1);
pn[0]=0;
pn[1]=0;
for(int i=2;i<=1000000/2;i++){
	if(pn[i]==1){
		for(int j=2;j<=1000000/i;j++){
			pn[j*i]=0;
		}
	}
}
	while(cin >> n){
		int ans=0;
		rep(i,n+1){
			if(pn[i])ans++;
		}
		cout << ans << endl;
	}


}

C++: #include <stdio.h>

int isPrime(int n);

int main(void){
    int n;
    int cnt;

    while (scanf("%d", &n)!= EOF){
        cnt = 0;
        for(int i=2; i<=n; i++){
            if (isPrime(i)) cnt++;
        }
        printf("%d\n", cnt);
    }

    return 0;
}


int isPrime(int n){
    int i;
    
    if (i%2==0) return 0;
    for (i=2; i*i<=n; i++){
        if (n%i==0) return 0;
    }
    return 1;
}

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



bool IsPrime[1000010];  //保证不做素数的倍数
int Prim[1000010];   //存素数
void euler_prime(int n){
    int num = 0, j;
    for(int i = 2; i <= n; i ++){
        if(!IsPrime[i])   //不是目前找到的素数的倍数    1不是素数
            Prim[num ++] = i;  //记录质数
        for(j  = 0; j < num; j ++){
            if(i * Prim[j] > n)
                break;
            IsPrime[i * Prim[j]] = true;  //筛;//找到的素数的倍数不访问
            if(i % Prim[j] == 0)
                break;  //i可以看做prime[j]*某个数， i*prime[j+1]就可以看做 prime[j]*某个数*prime[j+1] 。而 prime[j] 必定小于 prime[j+1]，所以 i*prime[j+1] 必定已经被 prime[j]*某个数 筛掉，就不用再做了（等到i=6即最大合因子时会筛掉）
        }
    }
}

int setans(int x)
{
    int cnt = 0;
    for(int i=2; i<=x; i++) {
        if(!IsPrime[i])
            cnt++;
    }
    return cnt;
}
int main()
{
    int n;
    euler_prime(1000005);
    while(scanf("%d",&n))

        printf("%d\n",setans(n));

    return 0;
}

C++: #include<iostream>
#define N 999999
int p[(N+1)/2];int m[N+1];int mk();using namespace std;int main(){int n;p[0]=2;m[1]=0;m[2]=1;mk();while(cin>>n){cout<<m[n]<<'\n';}return 0;}int mk(){int i,j,e=1;for(i=3;i<N;i++){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;
tag:m[i]=e;}}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}


vector<int> primes(100000);
int num_prime = 0; 

bool IsPrime(int m){
    if(m<2) return false;
    if(m==2) return true;
    if(m%2==0) return false;

    double root_m = sqrt(m);

    for(int i=3; i<=root_m; i+=2){
        if(m%i==0) return false;
    }

    return true;
}

void updatePrimes(int st, int max_v){
    for(int i=st;i < max_v+1; i+=2){
        if(IsPrime(i)){
            num_prime++;
            primes[num_prime] = i;
            // printf("%dは素数 ", i);
        }
    }
}
 
int main()
{
    primes[0] = 0;
    primes[1] = 2;
    primes[2] = 3;
    num_prime = 2;
    updatePrimes(5, 1000000);
    int num, id;

    while(scanf("%d", &num) != EOF){
        auto it = lower_bound(primes.begin(), primes.begin()+num_prime, num);
        if(*it > num) it--;
        id = it - primes.begin();
        printf("%d\n", id);
    }
    return 0;
}

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

#define MAX 1000000

int main(){
	bool p[MAX+1];
	int num,answer;

	while( scanf("%d" , &num) != EOF ){	
		// ツ陛渉青板づ個渉可甘コツ可サ
		p[0] = false;
		p[1] = false;
		for(int i=2 ; i<=MAX ; i++){
			p[i] = true;
		}
		answer = 0;

		//ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
		for(int i=2 ; i<=sqrt(MAX)+1 ; i++){
			if(p[i]==1){
				for(int j=i*2; j<=MAX; j=j+i){
					p[j] = false;
				}
			}
		}

		// Output
		for(int i=0; i<=num; i++){
			if(p[i]){
				answer++;
			}
		}
		printf("%d\n", answer);
	}
}

C++: #include<cstdio>
#include<cstring>
int main(){
	int a,b,d;
	while(~scanf("%d",&a)){
		int c[a+1];
		memset(c,0,sizeof(c));
		d=0;
		for(b=2;b<=a;b++){
			if(c[b]==0){
				d++;
				for(int i=b;i<a+1;i+=b)	c[i]=1;
			}
		}
		printf("%d\n",d);
	}
}

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

using namespace std;

int furui(int N){
  int i;
  int count=0;
  int array[1000000];
  array[0]=false;
  array[1]=false;
    
  for(i=2;i<=N;i++){
    array[i]=true;
  }

  for(i=2;i<=N;i++){
    if(array[i]==true)for(int j=i*i;j<=N;j+=i){
	array[j]=false;
      }
  }

  for(i=2;i<=N;i++){
    if(array[i]==true)count++;
  }

  return count;
}

int main(){
  int cnt=0,n;
  while(cnt<30){
    cnt++;
    cin >> n;
    cout << furui(n) <<endl;
}

  return 0;
}