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<cmath>
#include<fstream>
#include<iostream>

using namespace std;

int main(){
	int flag;
	long cnt;
	long N[30];
	for(int i=0;i<30;i++) cin >> N[i];
	for(int i=0;i<30;i++) {
		cnt = 0;
		for(int j=2;j<=N[i];j++) {
			flag = 1;
			for(int k=2;k<(sqrt(j))+1;k++) if(j!=k && 0==j%k) flag = 0;
			cnt += flag;
		}
		cout << cnt << endl;
	}
	return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  vector<bool> prime(1000000, true);
  vector<int> cnt(1000000, 0);
  for(int i=2;i<1000000;++i){
	cnt[i] = cnt[i-1];
	if(prime[i]){
	  ++cnt[i];
	  for(int j=i+i;j<1000000;j+=i)
		prime[j] = false;
	}
  }

  int n;
  while(true){
	if(!(cin >> n)) return 0;
	cout << cnt[n] << endl;
  }
  
  return 0;
}

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

int judgeprime(long num){
  int primeflag=1,i;

  if(num%2==0)primeflag=0;
  for(i=3;i<sqrt(num);i+=2){

    if( num%i==0 ){
      primeflag=0;
      break;
    }

  }

  if(num==0||num==1||num==4){primeflag=0;}
  else if(num==2){primeflag=1;}

  return primeflag;

}

int main(void){
  long i,num;
  int much;

  while( scanf("%ld",&num) != -1 ){

    much=0;

    for(i=1;i<=num;i++){
      much+=judgeprime(i);
    }

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

  }

  return 0;  
}

C++: #include <stdio.h>

#define MAX (999999)

int main(void)
{
	int i, j;
	bool p[MAX + 1] = {true};
	// ツェツ素ツ青板表ツ催ャツ青ャツづ可使ツづつスツェ
	int n, ans;
	
	// ツつアツづつゥツづァツ素ツ青板表ツ催ャツ青ャ
	p[0] = p[1] = true;
	for (int i = 2; (i * i) <= MAX; i++){
		if (p[i]){
			for (int j = 2; i * j <= MAX; j++){
				p[i * j] = false;
			}
		}
	}
	// ツつアツつアツづ慊づ！
	
	// ツ本ツ氾板つ「ツづつュツづヲツー
	while (scanf("%d", &n) != EOF){
		ans = 0;
		for (i = 0; i < n; i++){
			if (p[i]){
				ans++;
//				printf("%d:", i);
			}
		}
		printf("%d\n", ans);
	}
	
	return (0);
}

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 "stdio.h"
//#include"time.h"
const int MAX_V = 1000000; // 100????????§????´???°??¨?????????
int prime[MAX_V+1]; // 1????´???°,0????´???°??§?????????
int main() {
    int i, k, n;
//    clock_t start, now;//??£?¨?
    for(i = 2; i <= MAX_V; i++){
        prime[i] = 1; // 2??\???????´???°??¨??????
    }
    for(i = 2; i * i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°???2?????\???????????°????´???°??§?????????
            }
        }
    }
    while (1) {
        int cnt = 0;
        scanf("%d",&n);
//        start = clock(); // ????§???????
        if (n == EOF)break;
        for(i = n;1 <= i;i--){
            if(prime[i] == 1){  //??????????´???°
                cnt++;
            }
        }
//        now = clock(); // ????????????
        printf("%d\n",cnt);//for?????????????????????
//        printf("%f\n", (double)(now - start) / CLOCKS_PER_SEC);
    }
    return 0;
}
//????¨??????¨????????????????????????

C++: #include <stdio.h>

int main(void){
	int i,j;
	int n;
	int cnt;
	int prime_cnt;

	while(scanf("%d",&n) != EOF){
		prime_cnt = 0;
		for(i = 0;i < n+1;i++){
			cnt = 0;
			if(i < 2) continue;
			if(i == 2){
				prime_cnt++;
				continue;
			}
			for(j = 2;j < i;j++){
				if(i % j == 0){
					cnt++;
					break;
				}
			}
			if(cnt == 0) prime_cnt++;
		}
		printf("%d\n",prime_cnt);		
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
 
 
// cin >>
// cin <<
bool isPrime(int x){
    if(x==2) return true;
    if(x<2||x%2==0) return false;
    int i=3;
    while(i<=sqrt(x)){
         if (x%i==0)return false;
        i= i+2;
    }
    return true;
}
int main(){
    int in[30]={};
    int out=0;
    for(int i=0;i<30;i++) cin >>in[i];
    for(int i=0;i<30;i++){
        if(in[i]==0){
            break;
        }else{
            out=0;
            for(int j=0;j<in[i]+1;j++){
				if(j%2!=0){
					if(isPrime(j)==true){
					out++;
					}
				}
            }
            cout <<out<<endl;
        }
    }
     
    return 0;
}

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;

	int c = 0;

	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;

int main()
{
	int n = 0, x = 0;
	int countdata[1000];
	while (cin >> n) {
		if (n / 1000000 > 0) {
			int count = 0;
			for (int a = 2; a <= n; a++) {
				if (a % 2 != 0 && a % 3 != 0 && a % 5 != 0 && a % 7 != 0) 
					count++;
				if (a == 2 || a == 3 || a == 5 || a == 7)
					count++;
			}
			countdata[x] = count;
			x++;
		}
	}
	for (int a = 0; a < x; a++) {
		cout << countdata[a] << endl;
	}
	return 0;
}