Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [40]int
	var inputCount, primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		resultArr[inputCount] = primeCount
		if inputCount == 30 {
			break
		}
		primeCount = 0
		inputCount++
	}
	for _, v := range resultArr {
		fmt.Printf("%d\n", v)
	}
}

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

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

int main()
{
  bool is_prime[1000000];fill(is_prime,is_prime+1000000,true);
  int count_prime[1000000];fill(count_prime,count_prime+1000000,0);
  is_prime[0]=false,is_prime[1]=false;
  for(int i=2;i<1000000;i++)
  {
    count_prime[i]=count_prime[i-1]+is_prime[i];
    if(!is_prime[i])continue;
    for(int j=i*2;j<1000000;j+=i)is_prime[j]=false;
  }
  int n;
  while(cin>>n)printf("%d\n",count_prime[n]);
}

C++: #include <iostream>

using namespace std;

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

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

#define MAX 1000000

int main(){
	bool p[MAX+1];
	int num,answer;

	while( scanf("%d" , &num) != EOF ){	
		p[0] = false;
		p[1] = false;
		for(int i=2 ; i<=MAX ; i++){
			p[i] = true;
		}
		answer = 0;

		for(int i=2 ; i<=sqrt(MAX)+1 ; i++){
			if(p[i]==1){
				for(int j=i*2; j<=MAX; j=j+i){
					p[j] = false;
				}
			}
		}

		for(int i=0; i<=num; i++){
			if(p[i]){
				answer++;
			}
		}
		printf("%d\n", answer);
	}
}

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

#include <math.h>

using namespace std;

static inline bool judge_prime(const int num) {
	if (num < 2) {
		return false;
	}
	else if (num == 2) {
		return true;
	}
	else if (num % 2 == 0) {
		return false;
	}
	else if (num == 3) {
		return true;
	}

	if (num % 3 == 0) {
		return false;
	}

	if(num % 6 != 1 && num % 6 != 5) {
		return false;
	}

	const double sqrtnum = sqrt(num);
	for(int i = 5; i <= sqrtnum; i += 6) {
		if(num % i == 0) {
			return false;
		}
		if (num % (i + 2) == 0) {
			return false;
		}
	}
	return true;
}

static int count_prime(const int input) {
	int counter_prime = 0;

	for (int i = input; 1 < i; i --) {
		if (judge_prime(i)) {
			counter_prime ++;
		}
	}
	return counter_prime;
}

int main() {
	int input;
	while(cin >> input) {
		cout << count_prime(input) << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n, cnt;	
	while(cin >> n){
		bool prime[n];
		prime[n] = {false};
		prime[1] = true;
		
		// ??¨??????????????????????????????
		for(int j = 2; j*j <= n; j++){
			if(prime[j] == false){
				for(int k = j; k*j <= n; k++){
					prime[j*k] = true;
				}
			}
		}
		cnt = 0;
		for(int i = 1; i <= n; i++){
			if(prime[i] == false) cnt++;
		}
		
		cout << cnt << endl;
	}
}

C++: #include<iostream>
#define N 999999
#define FOR(i,a,b) for( int i = ( a ); i < ( b ); i++ )
#define WHILE(n) while( std::cin >> n )
int p[(N+1)/2];int m[N+1];int mk();int main(){int n;p[0]=2;m[1]=0;m[2]=1;mk();WHILE(n){cout<<m[n]<<i'\n';}return 0;}int mk(){int i,j,e=1;REP(i,3,N_MAX){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}}

C++: #include<cstdio>
int sosu[1000000]={};
bool f[1000000]={false};
int main(){
  sosu[2] = 1;
  for(int i=3;i<=999999;i+=2){
    if(!f[i]){
      f[i] = true;
      if(i >= 1000) continue;
      for(int j=i*i;j<=999999;j+=i) f[j] = true;
      sosu[i] = 1;
    }
    sosu[i] += sosu[i-1];
    sosu[i+1] += sosu[i];
  }
  int n;
  while(scanf("%d",&n)!=EOF) printf("%d\n",sosu[n]);
  return(0);
}

C++: #include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1],sum[MAX_V+2]={0};
int main(){
  int n;
  for(int i = 2;i <= MAX_V;i++){
    prime[i] = 1;
  }
  for(int i = 2;i * i <= MAX_V;i++){
    if(prime[i]){
      for(int k = 2* i;k <= MAX_V;k += i)
      prime[k]=0;
    }
  }
  for(int i = 2;i < MAX_V;i++){
    sum[i] +=sum[i-1]+prime[i];
  }
  while(scanf("%d",&n)!=EOF){
    printf("%d\n",sum[n]);
  }
  return 0;
}

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

bool isPrime(unsigned int n);

int main()
{
    int n;
    while(cin>>n){
        int count=0;
        for(int i=0; i<=n; i++){
            if(isPrime(i)) count++;
        }
        cout << count << endl;
    }

    return 0;
}

bool isPrime(unsigned int n)
{
    if( n==0 || n==1 ) return false;
    if( n==2 ) return true;
    if(!(n%2)) return false;
    
    int rn = static_cast<int>(sqrt(n));
    
    bool flag = true;
    for(int i=3; i<=rn; i+=2){
        if(!(n%i)){
            flag = false;
            break;
                }
    }
    return flag;
}

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

using namespace std;
bool IsPrime[1000000];
vector<int> Prime;

void calc()
{
	for(int i = 0; i < 1000000; ++i)
	{
		IsPrime[i] = true;
	}
	for(int i = 2; i < 1000000; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 1000000; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	calc();
	int n;
	cin >> n;
	int count = 0;
	int a = Prime.size() - 1;
	while(Prime[count] <= n)
	{
		if(count >= a)
		{
			break;
		}
		count++;
	}
	cout << count << endl;
}

int main()
{
	solve();
	return(0);
}

C++: #include <bits/stdc++.h>
using  namespace std;
#define ll    long long int
#define pai     pair<int,int>
#define vi      vector<int>
#define vd      vector<double>
#define mpi     map<int,int>
#define mps     map<string,int>
#define sti     stack<int>
#define stc     stack<char>
#define sei     set<int>
#define ses     set<string>
#define multii  multiset<int>
#define MAX      10000010
bool prime[MAX];
void seive(){
memset(prime,true,sizeof(prime));
prime[0]=prime[1]=false;
for(int p=2;p*p<=MAX;p++){
       if(prime[p]){
    for(int i=p*p;i<=MAX;i+=p){
       prime[i]=false;
    }
}

}
}
int main(){
seive();
ll n;
int c=0;
while(cin>>n){
 for(int i=2;i<=n;i++){
   if(prime[i]){
    c++;
   }
 }
 cout<<c<<endl;
 c=0;
}

}

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

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

int main(){
	int n;
	
	while(cin >> n){
		int a=0;
		for(int i = 1; i <= n; ++i){
			if(prime(i))++a;
	}
		cout << a << '\n';
	}
}

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*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 n, m;
	while (cin >> n>>m){
		if (n==m) cout <<0 << endl;
		else {

		}
	}
	return 0;
}

C++: j,a['   '],s;main(i){for(;++i<1e6;){if(!a[i])for(j=i;j<1e6;)a[j+=i]=1;a[i]=s+=!a[i];}for(;~scanf("%d",&i);printf("%d\n",a[i]));}

C++: #include<iostream>
#include<string>
int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}