Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [40]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 <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define MAX_N 100000

using namespace std;
void q9() {
	bool IsPrime[MAX_N];
	memset(IsPrime, 1, sizeof(IsPrime));
	IsPrime[0] = false;
	IsPrime[1] = false;
	for (int i = 0; i < sqrt(MAX_N); i++) {
		if (!IsPrime[i]) continue;
		for (int j = i * 2; j < MAX_N; j += i) {
			IsPrime[j] = false;
		}
	}

	int NofP[MAX_N];
	NofP[0] = 0;
	for (int i = 1; i < MAX_N; i++) {
		NofP[i] = NofP[i - 1] + IsPrime[i];
	}

	int n;
	for (; cin >> n;) {
		cout << NofP[n] << endl;
	}
}

int main() {
	q9();
	return 0;
}

C++: #include<iostream>
#include<string>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int count=0;
		for(int i=2;i<=n;i++){
			int j=2;
			while(true){
				if(i%j==0)
					break;
				if(j>(int)sqrt((double)i)){
					count++;
					break;
				}
				j++;
			}
		}
		cout<<count+1<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

const int maxn = 1e6 + 15;
bool is_prime[maxn];
int sieve(int x){
	int res = 0;
	fill(is_prime+2,is_prime+x+1,true);
	for(int i = 2; i <= x; i++) if(is_prime[i]){
		res++;
		for(int j = 2 * i; j <= x; j += i) is_prime[j] = false;
	}
	return res;
}

int main(){
	int n;
	while(scanf("%d", &n) == 1) printf("%d\n", sieve(n));
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,count=0;
  while(scanf("%d",&n)!=EOF){
    int data[n+1];
    for(int i=2;i<=n;i++){
      data[i]=0;
    }
    for(int i=2;i<=n;i++){
      if(data[i]!=-1){
	count++;
	for(int j=i;j<=n;j+=i){
	  if(data[j]!=-1){
	  data[j]=-1;
	  }
	}
      }
    }
    cout << count << endl;
    count=0;
  }
  return(0);
}

C++: #include <stdio.h>
#include <string.h>
int main(void){
    int n,a,b;
    char x[1000000];
    while(~scanf("%d",&n)){
        memset(x,0,sizeof(x));
        for(a=2;a<=n/2;a++)for(b=a*2;b<=n;b+=a)x[b]=1;
        for(a=2,b=0;a<=n;a++)if(!x[a])b++;
        printf("%d\n",b);
    }
    return 0;
}

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

int main(){
	int n;
	int a[1000000];
	int b;
	int i, j, p;
	int c[30];
	p = 0;
	while (scanf("%d", &n) != EOF){
		b = (int)pow((double)n, 0.5);
		c[p] = 0;
		a[0] = -1;
		for (i = 2; i <= b; i++){
			for (j = 2; j <= n / i; j++){
				a[i*j - 1] = -1;
			}
		}
		for (i = 1; i <= n; i++){
			if (a[i - 1] != -1){ c[p]++; }
			a[i - 1] = 0;
		}
		p++;
	}
	for (i = 0; i < p; i++){
		printf("%d\n", c[i]);
	}
	return 0;
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
/*int main(){
    
    ll n;
    while (cin>>n) {
        vector<ll> v;
        for(int i=0;i<n+1;i++){
            v.push_back(i);
        }
        ll b=v[v.size()-1];
        for(int i=2;i<=n;i++){
            ll j=2;
            while(i*j<=b){
                v[i*j]=0;
                j++;
            }
        }
        ll ans=0;
        for(int i=0;i<v.size();i++){
           // cout<<v[i]<<endl;
            if(v[i]!=0)ans++;
        }
        cout<<ans-1<<endl;
    }
    
    
    return 0;
}*/
int main(){
    
    ll n;
    while(cin>>n){
        ll ans=0;
        for(int i=3;i<=n;i+=2){
            int flag=0;
        for(int j=3;j<=sqrt(i);j+=2){
            if(i%j==0){
                flag=1;
                break;
            }
        }
            if(flag==0){
                ans++;
            }
        
        
        
    }
        cout<<ans+1<<endl;
        }
    
    
    
    
    
    
    return 0;
}

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

int ary[40],ary2[1000010];
bool nopri[1000010];
int main(){
	int N;
	for(int i=1;i<=31;i++){
		cin>>ary[i];
		if(cin.eof()){
			N=i-1;
			break;
		}
	}

	int cnt=2;
	while(cnt<1000000){
		for(int i=2;i*cnt<1000000;i++){
			nopri[i*cnt]=true;
		}
		cnt++;
		while(nopri[cnt])cnt++;
	}
	cnt=0;
	for(int i=2;i<=1000000;i++){
		if(!nopri[i]) cnt++;
		ary2[i]=cnt;
	}
	for(int i=1;i<=N;i++){
		cout<<ary2[ary[i]]<<endl;
	}
	return 0;
}

C++: #include<stdio.h>

int prime[1000000];
bool flag[1000000];

void solve(int n)
{
	int ans=0;
	for(int i=2;i<=n;i++)
	{
		if(flag[i])
		{
			prime[ans++]=i;
			for(int j=2*i;j<=n;j+=i)
				flag[j]=false;
		}
	}
	printf("%d\n",ans);
}

int main()
{
	int data;
	while(scanf("%d",&data)!=EOF)
	{
		for(int i=0;i<=data;i++)
			flag[i]=true;
		flag[0]=flag[1]=false;
		solve(data);
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
  vector<bool> is_prime(1000000, true);
  is_prime[0] = false; is_prime[1] = false;

  for(int64_t i=2; i<1000000; i++){
    if(is_prime[i]){
      for(int64_t j=2; i*j<1000000; j++) is_prime[i*j] = false;
    }
  }

  int n;
  while(cin >> n){
    int ans = 0;
    for(int i=0; i<=n; i++){
      if(is_prime[i]) ans++;
    }
    cout << ans << endl;;
  }
}

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

int count(int n);

int main(void){
	while (true){
		int n; cin >> n;
		if (!n){
			break;
		}
		cout << count(n) << endl;
	}
	return 0;
}

int count(int n){
	int ct = 0;
	bool *prime = new bool[n];
	//bool prime[999999];
	for (int i = 0; i <= n;i++){
		prime[i] = 0;
	}
	prime[2] = 1;
	for (int i = 3; i <= n; i = i + 2){
		prime[i] = 1;
	}
	for (int i = 3; i <= sqrt(n); i = i + 2){
		if (prime[i] == 0) continue;
		for (int j = i * 2; j <= n; j = j + i){
			prime[j] = 0;
		}
	}
	for (int i = 3; i <= n; i = i + 2){
		if (prime[i] == 1) ct++;
	}
	ct++; //2を数えていない分
	delete[] prime;
	return ct;
}

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

int main(){
  bool is_prime[1000000];

  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<1000000i++){
    is_prime[i] = true;
  }

  for(int i=2;i*i<1000000;i++){
    if(is_prime[i]){
      for(int j=i*i;j<1000000;j=j+i){
        is_prime[j] = false;
      }
    }
  }

  int n_prime[1000000];

  int cnt = 0;
  for(int i=0;i<1000000;i++){
    if(is_prime[i]){
      cnt++;
    }
    n_prime[i] = cnt;
  }

  while(true){
    int n;
    cin >> n;

    if(cin.eof())
        break;

    cout << n_prime[n] << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int a,b,c=0;
	while(cin>>a){
		for (int A=2;A<=a;A++){
			for (int B=2;B<=A;B++){
				b=A%B;
				if (A==B){
					c++;
					break;
				}
				if (b==0) break;
			}
		}
		cout<<c<<endl;
		c=0;
	}
	return 0;
}