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 <cstdio>

typedef long long LL;

int p[100010];
bool np[1000010];
int cntp;

void SievePrime(int n) {
  LL t;
  for(int i = 2; i <= n; ++i) {
    if(!np[i]) p[cntp++] = i;
    for(int j = 0; j < cntp && (t = 1ll * i * p[j]) <= n; ++j) {
      np[t] = true;
      if(i % p[j] == 0) break;
    }
  }
}

int main() {
  SievePrime(1000000);
  int n;
  while(scanf("%d", &n) != EOF) {
    int ans = 0;
    for(int i = 2; i <= n; ++i) {
      if(!np[i]) ++ans;
    }
    printf("%d\n", ans);
  }
  return 0;
}

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

int main(void)
{
    int n, cnt;
    while (cin >> n) {
        cnt = 0;
        for (int i = 1; i <= n; ++i)
            if (n%i == 0)
                ++cnt;
        cout << cnt << endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>

using namespace std;

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



const int PS = 1000000;
int prime[PS];
int set_prime(){
	rep(i,PS)prime[i]=1;
	prime[0]=prime[1]=0;
	rep(i,PS){
		if(prime[i]==0)continue;
		for(int j=i*2;j<PS;j+=i)prime[j]=0;
	}
}


int sum[PS];
int set_sum(){
	set_prime();
	rep(i,PS)sum[i]=0;
	reps(i,1,PS)sum[i]=sum[i-1]+prime[i];
}
int main(){
	set_sum();
	
	int a;
	while(scanf("%d",&a)!=EOF){
		printf("%d\n",sum[a]);
	}
}

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

int main(){
  bool prime[1000000];
  int np[1000000], n;

  for(int i=2; i<1000000; i++){
    if(!prime[i]){
      for(int j=2; j*i<1000000; j++){
	prime[i*j] = true;
      }
    }
    np[i] = np[i-1] + !prime[i];
  }

  while(cin >> n)
    cout << np[n] << endl;

  return 0;
}

C++: #include<iostream>

int a,n[40],c[40];
int main (){
	for(int i=2;i<31;i++){
		n[i]=1;
		for(int j=2;j<i;j++){
		if(i%j==0){
			n[i]=0;
			j=i;
		}
		}
	}

	for(int i=1;i<31;i++){
		c[i]=c[i-1]+n[i];
	}
	while(scanf("%d"a)^){
		printf("%d",c[a]);
	}
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
int isprime(int x){
    if(x==2) return true;
    if(x<2||x%2==0) return false;
    else{
        int i=3;
        while(i<=sqrt(x)){
            if(x%i==0) return false;
            i = i+2;
        }
        return true;
    }
}
int main() {
    int n;
    while(cin >> n){
        int ans=0;
    for (int j=0; j<=n; j++) {
        if(isprime(j)!=0) ans++;
    }
    cout << ans << endl;
    }
}

C++: #include <cstdio>
int NUM = 1000000;
bool prime[NUM];
int main(){
  prime[0] = false;prime[1] = false;
  for(int i=2;i<NUM;i++)prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

	int primeNum[NUM];
	for(int i=0,c=0;i<NUM;i++){
		prime[i]&&c++;
		primeNum[i] = c;
	}
	for(int n;scanf("%d",&n)+1;printf("%d",primeNum[n]));
}

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

using namespace std;

int prime(int n) {
  int i, j, r;
  n++;
  vector<int> primes(n);

  for (i = 2; i < n; ++i)
    primes[i] = i;
  for (i = 2; i*i < n; ++i) {
    if (primes[i])
      for (j = i*i; j < n; j += i)
        primes[j] = 0;
  }
  for (i = r = 0; i < n; i++)
    if (primes[i]) r++;

  for (i = r; i < n; i++)
    cout << primes[i] << " ";
  cout << endl;
  return r;
}

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

C++: #include <iostream>
#include <cmath>
using namespace std;
bool isprime(int& num)
{
    static int c;
    if(num == 2) return true;
    for(c=2; c <= sqrt(num); c+=1)
        if(num % c ==0) return false;
    return true;
}

int main()
{
    int ans = 0;
    int buff;
    while(cin >> buff);
    {
        for(int d =2; d <= buff; d++)
        {
            if(isprime(d)) ans++;
        }
        cout << ans << " ";
        ans  = 0;
    }
    cout << endl;
    return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n;
	 
	bool prim[1000001];
	for(int i=0;i<1000001;i++) prim[i] = true;
	prim[1]=false;
	for(int i=3;i<1000001;i++){
		if(i%2==0) prim[i] = false;
		else if(prim[i]){
			for(int j=i*2;j<=1000001;j+=i) prim[j] = false;
		}
	}
	

	while(cin >> n){
		int ans=0;
		for(int i=1;i<=n;i++){
			if(prim[i]) ans++;
		}
		cout << ans << endl;
	}
}

C++: #include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int a[1000100];
int jud(int n){
	int i;
	for (i=2;i<=sqrt(n);i++){
		if (n%i==0)
		return 0;
	}
	return 1;
}
int main(){
	int n;
	while (cin>>n){
		int i,j,res=0;
		memset(a,0,1000000*sizeof(int));
		for (i=2;i<=n;i++)
		if (!a[i]){
			if (jud[i]){
			res++;
			if (i<1000){
			for (j=i*i;j<1000000;j+=i){
				a[j]=1;
			}
			}
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

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

int main()
{
	int n = 0, x = 0;
	int countdata[1000];
	while (cin >> n) {
		if (n / 1000000 > 0) {
			int count = 0;
			for (int a = 2; a <= n; a++) {
				if (a % 2 != 0 && a % 3 != 0 && a % 5 != 0 && a % 7 != 0 || a == 2 || a == 3 || a == 5 || a == 7) {
					count++;
				}
			}
			countdata[x] = count;
			x++;
		}
	}
	for (int a = 0; a < x; a++) {
		cout << countdata[a] << endl;
	}
}

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

int main(){
 int i,j,n,count,flg;
 scanf("%d",&n);
 for(i=2,count=0;i<=n;i++){
  for(j=2,flg=1;j<=i/2;j++)
   if(i%j==0){ printf("%d\n",i); flg=0; break; }
  count+=flg;
 }
 printf("%d\n",count);
 return 0;
}

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

#define MAX_NUM (1000000)

static int getPrimeNum(int maxVal);

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

static int getPrimeNum(int maxVal)
{
  static int searchList[MAX_NUM] = {0};
  static int primeList[MAX_NUM] = {0};
  
  for (int i = 0; i < MAX_NUM; i++) {
    searchList[i] = primeList[i] = 0;
  }
  
  double sqMaxVal = sqrt((double)maxVal) + 1;
  
  for (int i = 2; i <= sqMaxVal; i++) {
    if (searchList[i] == 0) {
      searchList[i] = 1;
      primeList[i] = 1;
      for (int j = i + 1; j <= maxVal; j++) {
        if (j % i == 0) {
          searchList[j] = 1;
        }
      }
    }
  }
  
  for (int i = 2; i <= maxVal; i++) {
    if (searchList[i] == 0) {
      primeList[i] = 1;
    }
  }
  
  int count = 0;
  for (int i = 2; i <= maxVal; i++) {
    if (primeList[i] == 1) {
      count++;
    }
  }
  
  return count;
}

C++: #include <iostream>
using namespace std;
#define x 1000000
int main(){
	bool q[x];
	for(int i=2;i<x;i++) q[i] = true;
	for(int i=2;i<x;i++) if(q[i]) for(int j=2;j<=x/i;j++) q[i*j] = false;
	int n;
	while(cin >> n){
		int a = 0;
		for(int i=2;i<x;i++) if(q[i]) a++;
		cout << a << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
    int a[100000];
    int n;
    a[0]=2;
    int k=1;
while(cin>>n){
    for(int i=3;i<=n;i++){
        for(int j=0;j<=k;j++){
            if(j==k){
                a[k]=i;
                k++;
                break;
             }
            if(i%a[j]==0)break;
        }
    }
    cout<<k<<endl;
    k=1;
 }
}