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++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
using namespace std;

int main(){
  int n;
  while(cin >> n){
    int ans=0;
    vector<int> vec;
    vec.push_back(2);
    for(int i = 3; i<=n; i+=2){
      bool isPrimeN = true;
      for(int j=3; j<=floor(sqrt(i)); j++){
        if(i%j==0){
          isPrimeN = false;
          break;
        }
      }
      if(isPrimeN){
        vec.push_back(i);
      }
    }
    cout << vec.size() << endl;;
  }
  return 0;
}

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




int main(){


	int Nmax = 1000000;
	bool isp[Nmax]={};
	int count[Nmax]={};

	isp[2] = true;
	for(int i=3;i<Nmax;i+=2){
		isp[i] = true;
	}

	for(int i=3;i<Nmax;i+=2){
		if(isp[i]){
			int j = i*2;
			while(j<Nmax){
				isp[j] = false;
				j += i;
			}
		}
	}

	for(int i=1;i<Nmax;i++){
		count[i] = count[i-1] + isp[i];
	}

	int n;
	while(cin >> n){
		cout << count[n] << endl;
	}

}

C++: #include<stdio.h>

int main(void){

	int sosuu[1000000],kazu,n,i,j;

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

		kazu=n-1;

		for(i=2;i<=n;i++){
			sosuu[i]=1;
		}
		sosuu[0]=0;sosuu[1]=0;

		for(i=2;i<=n;i++){
			if(sosuu[i]==1){
				for(j=i*2;j<=n;j+=i){
					if(sosuu[j]==1){
						kazu--;
						sosuu[j]=0;
					}
				}
			}
		}

		printf("%d\n",kazu);
		
	}

	return 0;
}

C++: #include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> prime;
void init(){
	for(int i=2;i<999999;i++){
		bool isprime=true;
		for(vector<int>::iterator p(prime.begin());p!=prime.end();p++){
			if(i%*p==0){
				isprime=false;
				break;
			}
		}
		if(isprime){
			prime.push_back(i);
		}
	}
}
int main(){
	int n;
	init();
	while(cin>>n){
		cout<<lower_bound(prime.begin(),prime.end(),n)-prime.begin()+1<<endl;
	}
	return 0;
}

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

#define N 1000000L
bool num[N];

void furui() {
	long int i;
	int divide;
	int rt = 1000;
	for (i = 0L; i < N; i++) {
		num[i] = true;
	}
	num[0] = false;
	num[1] = false;
	for (divide = 2; divide <= rt; divide++) {
		if (num[divide] == false) continue;
		for (i = (long int)divide; i < N; i += divide) {
			num[i] = false;
		}
		num[divide] = true;
	}
}

int main(void) {
	int c, i, j;
	long int k;
	char buf[7];
	long int n;
	long int count;

	furui();

	for (j = 0; j < 30; j++) {
		for (i = 0; ; i++) {
			c = getchar();
			if (c == EOF || c == '\n') {
				buf[i] = '\0';
				break;
			}
			buf[i] = c;
		}
		n = atol(buf);
		count = 0L;
		for (k = 1L; k <= n; k++) {
			if (num[k] == true) count++;
		}
		std::cout << count << std::endl;
		if (c == EOF) break;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a,x,i;
	while((scanf("%d",&a))!=EOF){
		x=0;
		for(i=0;i<a;i++){
			if((a-i)==1){
			}
			else if((a-i)%2!=0&&(a-i)%3!=0&&(a-i)%5!=0&&(a-i)%7!=0){
				x++;
			}
			else if((a-i)==2||(a-i)==3||(a-i)==5||(a-i)==7){
				x++;
			}
		}
		printf("%d\n",x);
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
int cnt,n,prime[1000000];
using namespace std;

void getprime()
{
	/*int tt=0,flag;
	prime[tt++]=2;
	for(int i=3;i<=1000000;i++) 
	{
		flag=1;
		for(int j=0;prime[j]*prime[j]<=i;j++)
		{
			if(i%prime[j]==0)
			{	
			    flag=0;
		     	break;
			}
		}
		if(flag==1) prime[tt++]=i;
	}*/
	memset(prime,0,sizeof(prime));  
    for(int i = 2; i<=1000000; i++)  
    {  
        if (!prime[i]) prime[++prime[0]] = i;  
        for(int j = 1;j<=prime[0] &&prime[j] < 1000000/i;j++ )  
        {  
            prime[prime[j]*i] = 1;  
            if(i%prime[j]==0) break;  
        }  
    } 
}

int main()
{	getprime();
	while(scanf("%d",&n))
	{
       for(int i=1;;i++){
       	if(prime[i]>n){
       		printf("%d\n",i-1);
       		break; 
		   }
	   }
    }
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main(){
	int i,j,n;
	static bool prime[1000001];
	for (i = 3; i <= 1000000; i += 2){
		prime[i] = true;
	}
	prime[2] = true;

	for (i = 3; i <= 1000; i += 2){
		if (prime[i] == 1){
			for (j = 3; j <= 1000000 / i; j += 2){
				prime[i * j] = false;
			}
		}
	}
	while(cin >> n && n){
		int count = 0;
		for(i=2;i<=n;i++){
			if(prime[i] == true) count++;
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <stdint.h>
using namespace std;

int sieve(int x)
{
  int ret = 0;
  vector<bool> v(x + 1, true);
  for (int i = 2; i <= x; i++) {
    if (v[i]) {
      ret++;
      for (int j = i + i; j <= x; j += i) {
        v[j] = false;
      }
    }
  }

  return ret;
}

int main()
{
  for (int n; cin >> n; ) {
    cout << sieve(n) << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
bool isPrime(long a) {
	if (a < 2) return false;
	long i;
	for (i = 2; i * i <= a; i++) {
		if (a % i == 0) return false;
	}
	return true;
}
signed main() {
	int Prime[1000000] = {};
	for (int i = 0; i < 1000000; i++) {
		if (isPrime(i)) {
			Prime[i] = 1;
		}
	}
	for (int i = 1; i < 1000000; i++) {
		Prime[i] += Prime[i - 1];
	}
	int n;
	while (cin >> n) {
		cout << Prime[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<math.h>
using namespace std;
int tim(int n)
{
	int i,s=0;
	int *a;
	a=new int [n+1];
	for(i=1;i<=n;i++)
	a[i]=1;
	for(i=2;i*i<=n;i++)
	{
		if(a[i]!=0)
		for(int j=i*i;j<=n;j=j+i)
		a[j]=0;
	}
	for(i=2;i<=n;i++)
	if(a[i]==1)
	{
	s=s+1;
   } 
	return s;
}
int main()
{
	int n,i=1;
	do
	{
		int k;
		cin>>n;
		if(n<2)
		k=0;
		else
		k=tim(n);
		cout<<k;
		cout<<endl;
	}
	while(1);
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


void initialize(vector<int> &search_list, int num);

void era(vector<int> &search_list, vector<int> &prime_list, int num);


int main(int argc, char* argv[]){

  int num;

  while (cin >> num){
    vector<int> search_list, prime_list;
    initialize(search_list, num);
    era(search_list, prime_list, num);
    cout << prime_list.size() << endl;
  }
  return 0;
}

void initialize(vector<int> &search_list, int num){
  for (int i=2; i<=num; ++i){
    search_list.push_back(i);
  }
  return;
}

void era(vector<int> &search_list, vector<int> &prime_list, int num){
  do{
    vector<int>::iterator it = search_list.begin();
    int count = 1;
    int N = *it;
    prime_list.push_back(*it);
    while ((N*count) <= num){
      it = find(search_list.begin(), search_list.end(), (N*count));
      if (it != search_list.end()){
        it = search_list.erase(it);
      }
      ++count;
    }
  } while (!search_list.empty());
}