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>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

const int MAX = 1000000;

bool prime[MAX];
int c[MAX];

int main() {
  rep (i, MAX) prime[i] = true;
  prime[0] = prime[1] = false;
  for (int i = 0; i * i <= MAX; ++i) {
    if (prime[i]) {
      for (int j = i * i; j < MAX; j += i) prime[j] = false;
    }
  }
  rep (i, MAX - 1) c[i + 1] = c[i] + (prime[i + 1] ? 1 : 0);
  int n;
  while (cin >> n) {
    cout << c[n] << endl;
  }
}

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

#pragma warning(disable:4996)

int main()
{
	int nCnt,nCnt2,In,Total,Count;

	Total = 0;

	scanf("%d", &In);

	for (nCnt = 2; nCnt <= In; nCnt++)
	{
		Count = 0;
		for (nCnt2 = nCnt; nCnt2 >= 2; nCnt2--)
		{
			if (nCnt%nCnt2 == 0)
			{
				if (nCnt != nCnt2)
					Count++;
			}
		}
		if (Count == 0)
			Total++;
	}

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

	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
bool prime[1000001];
int main(){
	int n;
		prime[1] = true;
		for(int i = 2; i * i <= 1000000; i++){
			if(!prime[i]){
				for(int j = i * i; j <= 1000000; j += i){
					prime[j] = true;
				}
			}
		}
	while(cin >> n){
		int ans = 0;
		for(int i = 1; i <= n; i++){
			if(!prime[i])ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	
	long int n,f,k,i;
	int count;
	bool chk;
	scanf("%d",&n);
		count=0;
		for(i=2;i<=n;i++){
		
			chk=0;
			f=i/2;
			k=2;
		
			while(f>=k){
				if((i%k)==0){
					chk=true;
					break;
				}
				k++;
			}
		
			if(chk==false){
				count++;
			}
		}
		cout<<count<<endl;
	
}

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

#define MAX 1000000
int prime[MAX];

int main()
{
	int number,count=0;
	prime[0] = prime[1] = 0;

	for(int i=2;i<MAX;i++)
	{
		prime[i] = 1;
	}
	for(int i=2;i<1001;i++)
	{
		if(prime[i])
		{
			for(int j=2*i;j<MAX;j += i)
			{
				prime[j] = 0;
			}
		}
	}

	while(cin >> number)
	{
		count = 0;
		for(int i=2;i<=number;i++)
		{
			count += prime[i];
		}
		printf("%d\n",count);
	}

	return 0;
}

C++: #include <cstdio>

int main(){
	int n;
	static bool c[1000000]={true};
	static int t[1000000];//t[0] = 0;
	for(int i = 2;i < 1000000;i++){
		if(!c[i]){
		for(int j = 2;i*j < 1000000;j++){
			c[i*j] = true;
		}
		}
		t[i]=t[i-1]+!c[i];
	}
	/*for(int i = 1;i < 1000000;i++){
		if(c[i])t[i]=t[i-1];
		else t[i] = t[i-1]+1;
	}*/
	for(int n;scanf("%d", &n);n++){
		printf("%d\n", t[n]);
	}
	
	while(scanf("%d", &n)){
		printf("%d\n", t[n+1]);
	}
	return 0;
}

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

int main(){
    int n;
    int result;
    int i, j;
    bool flug = false;

    while(cin >> n){
        for(i=2; i<n; i++){
            for(j=2; j<(int)sqrt(i)+1; j++){
                if(i % j == 0){
                    flug = true;
                    break;
                }
            }
            if(!flug) result++;
            flug = false;
        }

        cout << result << endl;
        result = 0;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;
int TestCase;



int main()
{
   while(cin >> TestCase)
   {
       int PrimeNumbers = 0;
       if(TestCase >= 2)
       {
           PrimeNumbers++;
       }
       for(int Sample = 3; Sample <= TestCase; Sample+=2)
       {
           if(Sample > 10)
           {
                if(Sample%3 != 0 && Sample%5 != 0 && Sample%7 != 0)
               {
                   PrimeNumbers++;
               }
           }
           else
           {
               if(Sample != 9)
               {
                   PrimeNumbers++;
               }
           }

       }
       cout << PrimeNumbers << endl;
   }

}

C++: #include<stdio.h>
const int MAX_V = 100;
int prime[MAX_V+1];
int main() {
  int i, k;
  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;
      }
    }
  }

  int right;
  int sum[MAX_V+1] = {0};
  sum[1] = 0;
  for(i = 1; i < MAX_V+1; i++){
    if(prime[i] == 1){
      sum[i + 1] = sum[i] + 1;
    }else{
      sum[i + 1] = sum[i];
    }
  }
  while(scanf("%d", &right) != EOF){
    printf("%d\n", sum[right + 1]);
  }
  return 0;
}

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

int prime[1000000];


bool isPrime(int n) {
  int x = (int)sqrt(n);
  for (int i = 3; i <= x; i += 2) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}


void get_prime(int max_num) {
  int primecount = 1;
  prime[2] = primecount;
  for (int i = 3; i <= max_num; i += 2) {
    if (isPrime(i))
      prime[i] = ++primecount;
    else
      prime[i] = primecount;
  }
}


int main () {
  int ns[31];
  int i = 0, max_num;
  while (std::cin >> ns[i]) {
    max_num = std::max(max_num, ns[i]);
    if (ns[i] % 2 == 0)
      ns[i] --;
    i ++;
  }
 
  return 0;
}

C++: #include <bits/stdc++.h>

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) REP (i, 0, n)
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

const int MAX_N = 100000000;
bool prime[MAX_N];
void eratos() {
	rep(i, MAX_N) prime[i] = true;
	prime[0] = false;
	prime[1] = false;
	REP(i, 2, sqrt(MAX_N)) {
		if (prime[i]) {
			for (int j = 0; i * (j + 2) < MAX_N; ++j) {
				prime[i * (j + 2)] = false;
			}
		}
	}
}

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

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

int main()
{
	const size_t MAX = 1000000;

	bitset<MAX> primebox;
	primebox.set();
	primebox.reset(0);
	primebox.reset(1);

	for(int i = 2; i < MAX; i++)
	{
		if(!primebox.test(i))
			continue;

		for(int j = i*2; j < MAX; j += i)
			primebox.reset(j);
	}
		cout << "ok" << endl;

	size_t n;
	while(cin >> n)
	{
		int found;
		if(n < 2)
			found = 0;
		else if(n == 2)
			found = 1;
		else
		{
			found = 1;
			for(size_t i = 3; i <= n; i += 2)
				if(primebox.test(i))
					found++;
		}

		cout << found << endl;
	}

	return 0;
}

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

using namespace std;

int prime(int a){
    int sqt = sqrt(a);
    int array[a+1];
    array[1] = 1;
    array[2] = 0;
    array[3] = 0;
    if(a >= 4){
        for(int i = 2; i <= sqt; i++){
            for(int j = 2; j*i <= a; j++){
                array[i*j] = 1;
            }
        }
    }
    int count = 0;
    for(int i = 1; i <= a; i++){
        if(array[i] == 0) count++;
    }
    return count;
}

int main(){
    int n;
    while(cin >> n){
        cout << prime(n) << endl;
    }
}