Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := 2; j < MAX/i; j++ {
                                if i * j < MAX {
                                        primes[i*j] = 0
                                }
                        }
                }
        }
}

C++: #include <iostream>

int prime_number_count(const int n)
{
    int cnt;
    bool was_not_divisible;
    
    if (n < 2){
        return 0;
    }
    
    cnt = 1;
    for (int i = 3; i <= n; i += 2){  // dividend: 被除数
        was_not_divisible = true;
        for (int j = 3; j < i; j += 2){  // divisor: 除数
            if (i % j == 0){
                was_not_divisible = false;
                break;
            }
        }
        if (was_not_divisible){
            cnt++;
        }
    }
    
    return cnt;
}

int main()
{
    int n;
    
    while (std::cin >> n){
        std::cout << prime_number_count(n) << std::endl;
    }
    
    return 0;
}

C++: #include<stdio.h>

int main(void){
  int n;
  while(scanf("%d",&n)!=EOF){
    if(n==1){
      printf("%d\n",0);
      break;
    }
    int p[1000000];
    p[0]=2;
    int pi=1;
    int i=2;
    while(i<=n){
      int t=1;
      int j;
      for(j=0;j<pi;j++){
	if(i%p[j]==0){
	  t=0;
	  break;
	}
      }
      if(t==1){
	p[pi]=i;
	pi++;
      }
      i++;
    }
    printf("%d\n",pi);
  }
  return 0;
}

C++: #include<stdio.h>
int main(void)
{
    int n,i,j,z,x;
	
    scanf("%d",&n);
	while(1<=n<=999999){
		for(i=2;i<=n;i++){
			z=0;
			for(j=2;j<=i;j++){
				if(i%j==0 && i!=j){
					z++;
					break;
				}
			}
			if(z==0){
				x++;
			}
		}
		printf("%d\n",x);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include <stdio.h>
int isprime(int n){
	int i;
	for(i=2;i<n;i++){
		if(n % i == 0){
			return 0;
		}
	}
	return 1;
}
int main(){
	int i,n,c=0;
	scanf("%d",&n);
	for(i=2;i<=n;i++){
		if(isprime(i) == 1){
			c++;
		}
	}
	printf("%d",c);
	return 0;
}

C++: #include <iostream>

#define MAX_N 999999

unsigned long long int n;
bool cache[MAX_N+1];

void make_cache(void)
{
    for (int i = 0; i <= MAX_N; i++) {
        cache[i] = true;
    }

    for (int i = 2; i <= MAX_N; i++) {
        if (cache[i]) {
            for (int j = i + i; j <= MAX_N; j += i) {
                cache[j] = false;
            }
        }
    }
}

void solve(void)
{
    int count = 0;
    for (int i = 2; i <= n; i++) {
        if (cache[i]) count++;
    }
    std::cout << count << std::endl;
}
        

int main(void)
{
    make_cache();
    while (std::cin >> n) {
        if (n == 0) break;
        solve();
    }
    return 0;
}

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

int main(){
	int ans[1000000];
	int count=2;
	
	for(int i=4;i<1000000;i++){
		bool p=true;
		double sqrti = i;
		for(int j=2;j<=sqrt(sqrti);j++){
			if(i % j == 0){
				p=false;
				break;
			}
		}
		if(p){
			count++;
			ans[i]=count;
			}
		else ans[i]=count;
	}
	ans[1] = 0;
	ans[2] = 1;
	ans[3] = 2;
	
	int n;
	
	while(scanf("%d",&n)==1){
		printf("%d\n",ans[n]);
	}
	return 0;
}

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

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

const int MAX = 1000000;
bool isPrime[MAX+1];
int sum[MAX+1];

int main() {
	fill(isPrime, isPrime + MAX + 1, true);
	fill(sum, sum + MAX + 1, 0);
	for(int i = 2; i <= MAX; i++) {
		sum[i] = sum[i - 1];
		if(isPrime[i]) {
			sum[i]++;
			if(i*i <= MAX) {
				for(int j = 2 * i; j <= MAX; j += i)
					isPrime[j] = false;
			}
		}
	}
#if 0
	for(int i = 0; i < 20; i++) {
		cout << i << " " << isPrime[i] << " " << sum[i] << endl;
	}
#endif
	for(int n; cin >> n;) {
		cout << sum[n] << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
const int MAX = 1000000;

int main(){
	bool b[MAX] = {true};
	static int a[MAX] = {0,0};
	int n;
	for(int i = 2;i < MAX;i++){
		if(!b[i]){
			for(int j = 2;i*j < MAX;j++){
				b[i*j] = true;
			}
		}
		a[i] = a[i-1] + !b[i];
	}
	while(cin >> n){
		cout << a[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<memory>
#include<array>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
  int n;

  while ( cin >> n )
    {
      unique_ptr<int[]> tbl(new int[n+1]);
      for ( int i = 2; i <= n; i++ )
        tbl[i] = 1;

      for ( int i = 2; i <= n; i++ )
        if ( tbl[i] == 1 )
          {
            int j = i * 2;
            while ( j <= n )
              {
                tbl[j] = 0;
                j += i;
              }
          }

      int ret = 0;
      
      for ( int i = 2; i <= n; i++ )
        ret += tbl[i];

      cout << ret << endl;
    }
  
  return 0;
}

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

using namespace std;

#define MAX_NUM	1000000

int solist[MAX_NUM] = { 0 };

int main(int argc, char* argv[])
{
	int i; 
	int num;
	int count;
	int val;

	solist[0] = 1;
	solist[1] = 1;

	for (num = 3; num < MAX_NUM; num += 2) {
		if (solist[num]) continue;
		for (i = num * 2; i < MAX_NUM; i += num) {
			solist[i] = 1;
		}
	}

	while (cin >> val) {
		count = 1;
		for (i = 1; i <= val; i += 2) {
			if (solist[i] == 0) {
				count++;
			}
		}
		cout << count << endl;
	}
	
	return 0;
}

C++: #include<stdio.h>
#define MAX 1000//1000010

int main(){
	bool prime[MAX];
	prime[0]=prime[1]=0;
	for(int i=0;i<MAX;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	for(int i=2;i<MAX;i++){
		if(prime[i]==1){
			for(int j=2;i*j<MAX;j++){
				prime[i*j]=0;
			}
		}
	}
	int prime_under_num[MAX];
	prime_under_num[0]=0;
	for(int i=1;i<MAX;i++){
		prime_under_num[i]=prime_under_num[i-1]+prime[i];
	}
	
	int n;
	while((scanf("%d",&n))!=EOF){
		printf("%d\n",prime_under_num[n]);
	}
	
	
}

C++: #include<iostream>
using namespace std;
int main(){
int a,i;
cin>>a;
for(int x=0;x<a;x++){
if(a%x){i++}
cout<<i<<endl;
}
return 0;
}