Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		flag := false
		count := 0

		for i := 2; i <= num; i++ { //1を除く入力値以下の数字
			for j := 2; j < i-1; j++ {
				if i%j == 0 && j != 1 {
					flag = true
					//fmt.Println(i, "/", j)
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

C++: #include<iostream>

using namespace std;

int main(){
  int n;
  int *prime;
  int i,j;
  while(cin >> n){
    //init
    prime = new int[n+1];
    for(i=0; i<=n; i++) prime[i] = 0;

    //素数判定
    for(i=2; i*i<=n; i++){
      if(prime[i] == 0){
	prime[i] = 1; //iは素数
	for(j=2; i*j<=n; j++){//倍数ふるい落とし
	  prime[i*j] = -1;//i*jは素数じゃない
	}
      }
    }
    for(i=i; i<=n; i++){
      if(prime[i] == 0) prime[i] = 1;
    }
    
    //output
    int ans=0;
    for(i=2; i<=n; i++){
      if(prime[i] == 1) {
	ans ++;
	//cout << "prime:" << i << endl;;
      }
    }
    cout << ans << endl;

    delete[] prime;
  }
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    for(;;){
        int n;
        if(!(cin >> n))
            return 0;
        vector<bool> prime;
        makePrimeNumber(n, prime);
        int ret = 0;
        for(int i=0; i<=n; ++i)
            if(prime[i])
                ++ ret;
        cout << ret << endl;
    }
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int prime[100000] = {0};

void makeprime(long long int n)
{
    int k = 1;
    prime[0] = 2;
    for (long long int i = 3; i < n; i++)
    {
        double temp = sqrt(i);
        for (int j = 0; i % prime[j] != 0; j++)
        {
            if (temp < prime[j])
            {
                prime[k++] = i;
                break;
            }
        }
    }
    // rep(i,1000){
    //     cout<<prime[i]<<" ";
    // }
}

int main()
{
    makeprime(999999);
    int n;
    int i;
    while (cin >> n)
    {
        i = 0;
        while (true)
        {
            if (n < prime[i])
            {
                break;
            }
            i++;
        }
        cout << i << endl;
    }
    return 0;
}

C++: #include<cstdio>

int main(){
	int f[1000001] = {};
	int n;

	for(int i = 2; i < 500001; i++){
		f[i * 2] = 1;
	}

	for(int i = 3; i <= 1000; i += 2){
		for(int j = 3; j * i <= 1000000; j += 2){
			f[i * j] = 1;
		}		
	}

	int sum;

	while(scanf("%d", &n) + 1){
		int sum = n - 1;
		while(n){
			if(f[n]){
				sum--;
			}
			n--;
		}
		printf("%d\n", sum);
	}
	return 0;
}

C++: #include<cstdio>

int main(){
	int f[1000001] = {};
	int n;

	for(int i = 2; i < 500001; i++){
		f[i * 2] = 1;
	}

	for(int i = 3; i <= 1000; i += 2){
		for(int j = 3; j * i <= 1000000; j += 2){
			f[i * j] = 1;
		}		
	}

	int sum;

	while(scanf("%d", &n) + 1){
		int sum = n - 1;
		for(int i = 2; i <= n; i++){
			sum -= f[i];
		}
		printf("%d\n", sum);
	}
	return 0;
}

C++: // 2011/06/04 Tazoe

#include <iostream>
using namespace std;

void eratos(bool prime[], int n)
{
	if(n>=1)
		prime[0] = false;
	if(n>=2)
		prime[1] = false;

	for(int i=2; i<n; i++)
		prime[i] = true;

	for(int i=2; i<n; i++){
		if(!prime[i])
			continue;
		for(int j=i+i; j<n; j+=i)
			prime[j] = false;
		if(n<i*i)
			return;
	}
}

int main()
{
	bool prime[1000000];
	eratos(prime, 1000000);

	while(true){
		int n;
		cin >> n;
		if(cin.eof())
			break;

		int cnt = 0;
		for(int i=0; i<=n; i++)
			if(prime[i])
				cnt++;

		cout << cnt << endl;
	}

	return 0;
}

C++: #include <stdio.h>

int main(){
	long sosuu[200000] = { 2 }, i, x, y = 1, z = 0;

	while(scanf("%d", &z)!=EOF){//入力した数以下の素数を表示

		for (i = 3; i < z + 1; i += 2){
			for (x = 0; x < y; x++){
				if (i % sosuu[x] == 0){ break; }
				if (x + 1 == y){ sosuu[y] = i, y++; }
			}
		}
		if (z < 2){ y = 0; }
	printf("%d\n", y);//最後に素数の合計数を表示

	for (i = 1; i < y; i++){
		sosuu[i] = 0;
	}y = 1; z = 0;
	}

	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<1000000;i++){
        is_prime[i]=true;
    }

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

    int cnt=0;
    int n_prime[1000000];
    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 <math.h>
using namespace std;
int isPrime(int n){
    int i;
    if(n == 2)  return true;
    else if(n < 2 || n % 2 == 0)    return false;
    else{
        i = 3;
        while(i <= sqrt(n)){
            if(n % i == 0)  return false;
            i += 2;
        }
    }
    return true;
}
 
int main(void){
    int n, i, cnt;
    while(cin >> n){
        cnt = 0;
        for(i = 2; i <= n; i++){
            if(isPrime(i))  cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

C++: #include<stdio.h>
int main(){
			int a,b,c,n;

	while(scanf("%d",&n) != EOF){
		c=0;
			for(a=2;a<=n;a++){
				for(b=2;b<=n;b++){
					if(a%b==0&&a!=b){
						break;
					}else if(a%b==0&&a==b){
						c++;
					}else{
					}
				}
			}
			printf("%d\n",c);
	}
	return 0;
}

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

#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<vector>

using namespace std;

#define Max(a,b) (a)>(b)?(a):(b);
#define Min(a,b) (a)<(b)?(a):(b);
int prime[1000000];
int main()
{
    prime[0]=1;
    prime[1]=1;
    long long i,j;
    for(i=2;i*i<=1000000;i++){
        if(prime[i]==0)
        for(j=i+i;j<=1000000;j+=i){
            prime[j]=1;
        }
    }

    int cnt = 0;
    for(i=2; i<1000000;i++){
        if(prime[i]==0)prime[i]= ++cnt;
        else prime[i]= cnt;
    }

    int n;
    while(scanf("%d",&n)==1)
    {
        if(n<2){cout<<"0"<<endl; continue;}

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

    return 0;
}

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

using namespace std;

long* primes(long high)
{
  long* p = new long[high];
  for (int i = 0; i < high; i++) {
    p[i] = 0;
  }

  long max = ceil(sqrt(high));
  for (int i = 2; i <= max; i++) {
    if (p[i - 1] == -1) continue;

    int count = 2;
    while (i * count <= high) {
      p[i * count - 1] = -1;
      count++;
    }
  }

  for (int i = 1; i < high; i++) {
    if (p[i] == -1) {
      p[i] = p[i - 1];
    } else {
      p[i] = p[i - 1] + 1;
    }
  }
  
  return p;
}

int main(int argc, char const* argv[])
{
  long* p = primes(999999);
  long n;

  while (cin >> n) {
    cout << p[n - 1] << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int n , ans = 1;

	cin >> n;

	for(int i = 2; i <= n; i++){
		if(i % 2 != 0 && 9 > i){
			//cout << i << endl;
			ans++;

		}if(i >= 9){
			if(i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0){
				//cout << i << endl;
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}