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] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

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

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T &n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

bool isprime(int n){
  if(n==2||n==3) return true;
  for(int i=2; i*i<=n; i++) if(n%i==0) return false;
  
  return true;
}

bool prime[1000005]={true};

signed main(){
  int n;
  while(cin>>n){
    if(n==1){cout<<0<<en; RE;}
    int ans=0;
    for(int i=2; i<=n; i++){
      if(isprime(i)&&prime[i]) {
        ans++;
        for(int j=i; j<=n; j+=i) prime[j]=false;
      }
    }
    cout<<ans<<en;
  }
}

C++: #include <iostream>

using namespace std;
int prime(int n){ 
        bool* notprime = new bool[n+1];
        int counter = 0;
        for(int i = 2 ; i <= n ; i++){ 
                if(!notprime[i]){
                        counter++;
                        for(int j = 2 ; j*i <= n ; j++){
                                notprime[j*i] = true;
                        }   
                }   
        }   
        return counter;
}
int main(){
        int n;
        while(cin >> n){ 
                cout << prime(n) << endl;
        }   
}

C++: import math

while True:
    try:
        n = int(input())
        c = [1 for i in range(n)]
        c[0] = 0
        i = 2
        while i**2 <= n:
            j = i*2
            while j <= n:
                c[j - 1] = 0
                j += i
            i += 1
        print(sum(c))
    except:
        break

C++: #include <iostream>
using namespace std;
char s[1000004];
int  d[1000004];
int main( void )
{
  int M=1000000;
  int n=0;
  for( int i=2; i<M; i++ ){
    if( !s[i] ){
      int j=i*2;
      while( j < M ){ s[j]=1; j+=i; }
      n++;
    }
    d[i] = n;
  }
  while( 1 ){
    cin >> n;
    if( cin.eof() ) break;
    cout << d[n] << endl;
  }
  return 0;
}

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

int main()
{
	long int n,m;
	while(cin>>n){
		long int i;
		int number[10000000]={0};
		int ans=0;

		for(i=2;i<n;i++){
			if(number[i]==0){
				ans++;
				for(m=i;m<n;m+=i){
					number[m]=1;
				}
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include <stdio.h>

int IsPrime(int n);

int main(void){
    int n, cnt, minID, min=1;
    int list[100000];

    cnt=0;
    for (int i=0; i<1000000; i++){
        if (i%10==0) list[i/10] = cnt;
        cnt += IsPrime(i);
    }
    while (scanf("%d", &n) && n!=EOF){
        cnt = list[n/10];
        for (int i=1; i<n%10; i++){
            cnt += IsPrime(i);
        }
        printf("%d\n", cnt);
    }
    return 0;
}

inline 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 <iostream>

using namespace std;

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

	return true;
}

int main()
{
	int N[3] = { 0, 0, 0 };
	int C[3] = { 0, 0, 0 };

	cin >> N[0] >> N[1] >> N[2];

	for (int i = 0; i < 3; i++)
	{
		for (int j = 2; j <= N[i]; j++)
		{
			if (isprime(j) == true)
			{
				C[i] += 1;
			}
		}
	}

	cout << C[0] << endl << C[1] << endl << C[2] << endl;

	return 0;
}

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

int main(){

	int n, i, j, prmnum;
	bool prm = true;
	double sqrootm,sqrootp;

	while(cin>>n){
		if(n==0)prmnum=0;
		else if(n==1)prmnum=0;
		else if(n==2)prmnum=1;
		else{

			prmnum = 2;

			for( i=6; i<=n+1; i+=6 ){
				prm = true;

				sqrootm = sqrt((double)(i-1));
				sqrootp = sqrt((double)(i+1));

				for( j=3;j<=sqrootm;j+=2 ){
					if( (i-1)%j == 0 ){
						prm = false;
						break;
					}
				}
				if(prm)prmnum++;

				prm = true;

				if( i!=n+1 ){
					for( j=3;j<=sqrootp;j+=2 ){
						if( (i+1)%j == 0 ){
							prm = false;
							break;
						}
					}
				}
				if(prm)prmnum++;
			}
		}






		cout << prmnum << endl;


	}
	return 0;
}

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

#define MAX_N 2000000
int prime[MAX_N];



int main(){
	prime[1] = 1;
	prime[2] = 0;
	prime[3] = 0;
	for(int i = 2; i<=MAX_N;i++){
		if(prime[i] == 0)
			for(int j=2*i;j<=MAX_N;j=j+i)
				prime[j] = 1;
	}
	
	int n;
	int num=0;
	while(cin.eof()==0){
		cin >> n;	
		for(int k = 1;k<=n; k++){
			if(prime[k]==0)
				num++;
		}
		cout << num << endl;
		num = 0;
	}
	return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
ll prime[1000001];
ll length = 0;
void insert(ll p) { prime[length] = p; length++; return; }
int main(){
	insert(2);
	for (ll i = 3; i < 1000000; i += 2) {
		for (ll j = 0; j < length; j++)
			if (i%prime[j] == 0)goto cont;
			else if (prime[j] > sqrt(i))break;
		insert(i);
	cont:;
	}
	ll n; while (cin >> n) {
		ll ans = 0;
		while (prime[ans] <= n&&ans < length) {
			ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() 
{
  int a=999999;
  bool list[a+1];
  memset(list,true,sizeof(list));
  list[1]=false;
  for(int i=4;i<=a;i=i+2)
  {
    list[i]=false;
  }
  for(int i=3;i*i<=a;i=i+2)
  {
    if(list[i]==true)
    {
      for(int k=i*i;k<=a;k=k+i+i)
      {
        list[k]=false;
      }
    }
  }
  int temp;
  while(scanf("%d",&temp))
  {
    int count=0;
    for(int i=1;i<=temp;i++)
    {
      if(list[i]==true)
      {
        count++;
      }
    }
    printf("%d\n",count);
  }
  
}

C++: #pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	memset(vis, 0, sizeof(vis));
	memset(prime, 0, sizeof(prime));
	prime[0] = prime[1] = 0;
	for (int i = 2; i<= MAX; i++){
		if (!vis[i]){
			prime[i] = 1;
			for (int j = i + i; j <= MAX; j += i){
				vis[j] = 1;
				prime[j] = 0;
			}
		}
	}
	int sum = 0;
	for (int i = 0; i <= MAX; i++){
		if (prime[i]){
			sum++;
		}
		amount[i] = sum;
	}
	int n;
	while (cin >> n){
		cout << amount[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	long long n,i,s;
	while(cin>>n)
	{
		s=0;
		for(i=2;i<=n;i++)
		{
			if(i==2||i==3||i==5||i==7)s++;
			else if(i%2!=0&&i%3!=0&&i%5!=0&&i%7!=0)s++;
		}
		cout<<s<<endl;
	}
	return 0;
}