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>
#include <cstdlib>

using namespace std;

int main(void){
  const int n = 1000000;
  bool* check_A = (bool*)malloc(sizeof(bool)*n);
  int*  num_A   = (int*)malloc(sizeof(int)*n);
  int N = 0, temp = 2;
  memset(check_A, true, n);
  check_A[0] = false;
  check_A[1] = false;
  num_A[0] = 0;
  num_A[1] = 0;
  for(int i = 0; i < n; i++){
    if(check_A[i]){
      for(;temp < i;temp++){
	num_A[temp] = N;
      }
      temp++;
      num_A[i] = ++N;
      for(int j = 2; i*j < n; j++){
	check_A[i*j] = false;
      }
    }
  }
  int s;
  while(cin >> s){
    cout << num_A[s] << endl;
  }
  return 0;
}

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

int main(){

int i,j,n,count;

/**while(**/scanf("%d",&n);// != EOF){

count=2;

if(n<5){
	count=n-1;
}else{
	for(i=5;i<n+1;i+=2){
		for(j=2;j<(int)sqrt(i)+1;j++)

			if(i%j==0){
				break;
			}else if(j==(int)sqrt(i))
				count+=1;
	}
}

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

//}
return 0;		
}

C++: #include<stdio.h>
#include<math.h>
int isprime(int x){
	int i;
	if(x == 2){
 		return 1;
	}
  	if(x<2||x%2==0){
		return 0;
	}
	i = 3;
	while( i <= sqrt(x) ){
		if(x%i==0){
			return 0;
		}
		i = i + 2;
	}
	return 1;
}
int main(){
	int l[999999]={0};
	int r=0,n;
	for(int i=0;i<999999;i++){
		if(isprime(i+1)){
			r++;
			l[i]=r;
		}
	}
	while(scanf("%d",&n)!=EOF){
		printf("%d\n",l[n-1]);
	}
	return 0;
}

C++: #include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1];
int sum;
int main(){
 int i, k, v, n, left, right;
 while(scanf("%d", &n) != EOF) { 
 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;
   }
  }
 }
 sum= 0; 
 for(i= 0; i <= n; i++){
  sum = sum + prime[i];
 }
 printf("%d\n", sum);
 }
 return 0;
}

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

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

int main(){
  bool a[1000000];

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

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

  int n[1000000];

  int tmp=0;
  for(int i=0;i<1000000;i++){
    if(a[i]){
      tmp++;
    }
    n[i]=tmp;
  }

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

    if(cin.eof()){
      break;
    }
    
    cout<<n[m]<<endl;

  }

  return 0;
}

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

int main(){

  int n;

  while(cin>>n){

	int cnt=0;
	
	if(n <= 1){
	  cout<<0<<endl;
	  continue;
	}

	else
	  cnt++;
	
	for(int i=3;i<=n;i+=2){
	  int f = true;
	  for(int j=3;j<i;j+=2){
		if(i%j==0){
		  f = false;
		  break;
		}
	  }
	  if(f == true)
		cnt++;
	}

	cout<<cnt<<endl;
	
  }

  return 0;
  
}

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

int whether(int num);
int count(int num);

int main(){
	int n;
	int a;
	int b;

	while(1){
		b=feof(stdin);
		if(b!=0) break;
		scanf("%d",&n);
		a = count(n);
		printf("%d\n",a); 
	}

	return 0;
}

int whether(int num){
	int s=sqrt(num);
	int i;
	for(i=3; i<=s; i+=2){ if(num%i==0) return 0; }

	return 1;
}

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

	return a;
}

C++: #include <iostream>
#define MAX_N 1000000
using namespace std;
int main(){
	bool num[MAX_N];
	for(int i = 1; i < MAX_N; i++){
		num[i] = true;
	}
	num[0] = false;
	for(int i = 1; i < MAX_N; i++){
		if(num[i] == true){
			for(int j = 2*i+1; j < MAX_N; j += (i+1)){
				if((j+1) % (i+1) == 0){
					num[j] = false;
				}
			}
		}
	}
	int n;
	while(cin >> n){
		int prime = 0;
		for(int i = 1; i < n; i++){
			if(num[i] == true){prime++;}
		}
		cout << prime << endl;
	}
	return 0;
}

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

int main(){
	int  n,i,j,sqrtn,sum;
	while(scanf("%d",&n)!=EOF){
		sum=(n-1)/2;
		for(i=3;i<=n;i+=2){
			sqrtn=(int)sqrt(i);
			for(j=1;j*6-1<sqrtn;j++){
				if(i%(j*6+1)==0 || i%(j*6-1)==0){
					sum--;
					break;
				}
			}
		}
		printf("%d\n",sum);
		
	}
	return 0;
}

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+1)if(isPrime(i))v[i]=1;
   rui[1]=v[1];
   rep(i,2,999999+1)rui[i]=rui[i-1]+v[i];
   
   int n;
   while(cin>>n){
       cout<<rui[n]<<endl;
   }
   
    
    return 0;
}

C++: #include <iostream>

int main() {
	bool p[1000000];
	p[0] = p[1] = true;
	for( int i=2; i<1000000; i++) p[i] = false;
	
	int q[1000000];
	for( int i=2; i<1000; i++) if(!p[i]) for( int j=i*i; j<1000000; j+=i) p[j] = true;
	
	int sum = 0;
	for( int i=0; i<1000000; i++) {
		if(!p[i]) sum++;
		q[i] = sum;
	}
	
	int n;
	while( std::cin >> n) {
		std::cout << q[n] << std::endl;
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	int n, count;

	while ( cin >> n )
	{
		bool table[1000000];
		count = 0;

		for ( int i = 0; i <= n; i++ )
		{
			table[i] = true;
		}

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

		printf("%d\n", count );
	}

	return 0;
}

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

class SOSU{
   public:
      int sosu(int);
};
int SOSU::sosu(int n){
   int i,j,ans=0,flag;
   
   for(i=0;i<=n;i++){
      if(i<2)
         continue;
      
      else if(i==2 || i==3){
         ans++;
         continue;
      }
      
      if(i%2==0 || i%3==0)
         continue;
      
      flag = 0;
      for(j=2;j*j<=i;j++){
         if(i%j==0){
            flag++;
            break;
         }
      }
      if(flag==0)
         ans++;
   }
   return ans;
}

int main(){
   SOSU Sosu;
   int n,ans;
   while(cin>>n){
      ans = Sosu.sosu(n);
      printf("%d\n",ans);
   }
   return 0;
}