Go: package main

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

func main() {
    var limit = 1000000
    var root = 1000
    var isPrime [1000000]bool
    for i := 0; i < limit; i++ {
        isPrime[i] = true
    }
    isPrime[0] = false
    isPrime[1] = false
    for i := 2; i <= root; i++ {
        if isPrime[i] {
            for j := i * i;j < limit; j+=i {
                isPrime[j] = false
            }
        }
    }
    var primeCnt [1000000]int
    var cnt = 0
    for i := 0; i < limit; i++ {
        if isPrime[i] {
            cnt++
        }
        primeCnt[i] = cnt
    }

    var sc = bufio.NewScanner(os.Stdin)
    for sc.Scan() {
        n, _ := strconv.Atoi(sc.Text())
        fmt.Println(primeCnt[n])
    }
}

C++: #include <iostream>
using namespace std;
 
int main() {
	int N;
	bool is_prime[1000000];
	is_prime[0]=0; is_prime[1]=0;
	for(int i=2;i<1000000; i++){
		is_prime[i]=1;
	}
 
	for(int s=2; s<1000000; s++){
		if(is_prime[s]==1){	
		for(long long i=s*s; i<1000000; i+=s){
		is_prime[i]=0;	
 
		}
		}
	}
 
	while(cin >> N){
 
		int ans=0;
		for(int i=2; i<N+1; i++){
			ans+=is_prime[i];
		}
		cout << ans <<endl;
 
	}
return 0;
}

C++: /*
	大号水?，拿来?手
	靠，没仔?看?，明?需要素数打表
*/
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;

int prime_table[1000000];

int Find_Number (int x)
{
	int cnt = 0;
	for (int i=2;i<=x;i++)
	{
		bool flag = false;
		for (int j=2;j<=sqrt((double)i);j++)
		{
			if ( i % j == 0)
			{
				flag = true;
				break;
			}
		}
		if (flag == false )
		{
			cnt++;
		}
		prime_table[i] = cnt;
	}
	return cnt;
}

int main ()
{
	int N;
	Find_Number (1000000);
	while (scanf("%d",&N)!=EOF)
	{
		cout<<prime_table[N]<<endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream> 
#include <math.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std; 
int main(){
	int N;
	while(cin >> N)
	double p = std::log2(N);
	while (cin >> N){
		int sum =0;
		cout << N*p << endl;
	}
	return 0;
}

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

int main(){
	int n,s,a;
	
	while(cin >> n){
		a=0;
		for(int j=2;j<=n;j++){
			s=0;
			for(int i=2;i<j;i++){
				if(j%i==0){
					s++;
				}
			}
			if(s==0){
				a++;
			}
		}
		cout << a << "\n";
	}
		
	
return 0;
}

C++: #include<iostream>
#include<cstdio>
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;
	}
}

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

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;
}