Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2 || num == 5:
		return true
	case num < 2 || num%2 == 0 || num%5 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

C++: 
/* vo00_09.cpp */

#include <iostream>
using namespace std;

const int N = 1000000;
int prime[N];

void init();

int main()
{
	init();

	int n;
	while (cin >> n) {
		
		cout << prime[n] << '\n';

	}

	return 0;
}

void init()
{
	prime[0] = prime[1] = -1;

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

C++: #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())


int mem[1000000];
int ans[1000000];

int main(int argc, char const *argv[])
{
	int max_num = 1000000;
	int loop_max = sqrt(1000000);
	memset(mem, 0, 1000000);
	for (int i = 2; i < loop_max; i++)
	{
		int c = i * 2;
		while(c < max_num)
		{
			mem[c] = 1;
			c+= i;
		}
	}
	int n;
	int sum = 0;
	ans[0] = ans[1] = 0;
	for (int i = 2; i < max_num; i++)
	{
		sum += mem[i] ? 0 : 1;
		ans[i] = sum;
	}
	while(scanf("%d", &n) != EOF)
	{
		printf("%d\n", ans[n]);
	}
	return 0;
}

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

using namespace std;

int main(){
	int n,i,j,buf,cnt;

	scanf("%d",&n);

	while(n != EOF){
		cnt = 1;

		for(i=3;i<=n;i+=2){
			buf = (int)sqrt((double)i);

			for(j=3;j<=buf;j+=2){
				if((i % j) == 0){
					cnt--;
					break;
				}
			}

			cnt++;
		}

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

		scanf("%d",&n);
	}

	return 0;
}

C++: //============================================================================
// Name        : desk.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<stdio.h>
#include<iostream>
using namespace std;
int main(){

 int n=0,f=0,P=0;

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

 for(int i=2;i<n;i++){

	 if(n%i==0){
		f=1;
		}

 }

 if(f==0){
	 P++;
 }
 cout<<P<<endl;
 }

  return 0;
}

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

int main(){
	int n,t;
	while(scanf("%d",&n)!=EOF){
		int c=1;
		for(int i=3;i<=n;i+=2){
			int j=3;
			t=1;
			while( j <= sqrt(i) ){
				if(i%j==0){
					t=0;
				}
				j+=2;
			}
			if(t){
				c++;
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

C++: #include<cstdio>
#include<cstring>
using namespace std;
const int MAXN=1e7;
int is_prime[MAXN],prime[10000];
int sieve(int n){
	memset(is_prime,-1,sizeof(is_prime));
	int index=0;
	prime[0]=prime[1]=0;
	for(int i=2;i<=n;i++){
		if(is_prime[i])prime[index++]=i;
		for(int j=2*i;j<=n;j+=i)
		is_prime[j]=0;
	}
	return index;
}
int main(void){
	int n;
	while(scanf("%d",&n)!=EOF){
		printf("%d\n",sieve(n));
	}
	return 0;
}

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

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

int main(int argc, char** argv){
	
	int search, counter;
	
	while((scanf("%d", &search)) != EOF){
		counter = 0;
		for(int i = 2; i <= search; i++){
			counter += isPrimeNumber(i) ? 1 : 0;		
		}
		printf("%d\n", counter);
	}
	
	return 0;
}

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

#define MAX_SIZE (1000000)

int prime[MAX_SIZE];

int main()
{
	int n;

	prime[0] = prime[1] = 0;

	for (int i = 2; i < MAX_SIZE; i++){
		prime[i] = 1;
	}

	for (int i = 0; i < MAX_SIZE; i++){
		for (int j = i * i; j < MAX_SIZE; j += i){
			prime[j] = 0;
		}
	}

	for (int i = 1; i < MAX_SIZE; i++){
		prime[i - 1] += prime[i];
	}

	while (scanf("%d", &n) != EOF){
		printf("%d\n", prime[n]);
	}

	return (0);
}

C++: #include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;

int main(void) {
	int n;
	int count = 0;

	while (cin >> n) {
		count = 0;
		if (n >= 2) {
			count++;
		}
		FOR(i, 3, n) {
			FOR(t, 2, i - 1) {
				if (i%t == 0) {
					break;
				}
				if (t == i - 1) {
					count++;
				}
			}
		}
		cout << count << endl;
		
	}
	
	return 0;
}

C++: #include <stdio.h>

int IsPrime(int n);

int main(void){
    int n, cnt, minID, min=1;
    int max[30], sol[30], listID=0;
	
    while (scanf("%d", &n) && n!=EOF){
        cnt=0;
        min = 1;
        minID = 0;
        for (int i=0; i<listID; i++){
            if (max[i] < n && min <max[i]){
                min = max[i];
				cnt = sol[i];
            }
        }
        for (int i=min+1; i<=n; i++){
            if (IsPrime(i)) cnt++;
        }
        max[listID] = n;
        sol[listID] = cnt;
        listID++;
        printf("%d\n", cnt);
    }
    return 0;
}

int IsPrime(int n){
    int i;
    for (i=2; i*i<=n; i++){
        if (n%i==0) return 0;
    }
    return 1;
}

C++: #include <cmath>
#include <cstdio>
#include <map>
 
inline bool fermat_test(int n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else {
        return (static_cast<int>(std::pow(2, n - 1)) % n) == 1;
    }
}
 
inline bool prime_test(int n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else {
        for (int i = 3; i < static_cast<int>(std::sqrt(n)); i += 2) {
            if ((n %= i) == 0) {
                return false;
            }
        }
    }
    return true;
}

int m[999999];

int main() {
    m[3] = 2;
    int n;
    while (~scanf("%d", &n)) {
        if (n == 2) {
            printf("1\n");
            continue;
        }
        for (int i = 5; i <= n; i += 2) {
            if (m[i] > 0)
                continue;
 
            m[i] = m[i - 2] + (fermat_test(i) && prime_test(i));
        }
        printf("%d\n", m[n % 2 == 0 ? n - 1 : n]);
    }
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#pragma warning(disable:4996)

int main()
{
	
	int num, cnt;
	unsigned int i, j, k, data_num;
	int data[30];
	unsigned int sq_num;
	unsigned int *prime;

	for (data_num = 0; data_num <30; data_num++)
	{
		data[data_num] = -1;
		scanf("%d", &data[data_num]);
		if (data[data_num] < 0)
			break;
	}

	for (k = 0; k < data_num; k++)
	{

		sq_num = (int)sqrt((double)data[k]);
		prime = (unsigned int*)malloc(sizeof(unsigned int) * data[k]);
		prime[0] = 0;

		for (i = 1; i < data[k]; i++)
		{
			prime[1] = 1;
		}

		for (i = 1; i < sq_num; i++)
		{

			if (prime[i] == i)
			{
				for (j = (i + 1); (i + 1)* j <= data[k]; j++)
				{
					prime[(i + 1) * j - 1] = 0;
				}
			}
		}

		cnt = 0; 
		for (i = 0; i < data[k]; i++)
		{
			if (prime[i] == 1)
			{
				cnt++;
			}
		}
		printf("%d\n", cnt);
		free(prime);
	}

	return 0;
}