Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	a, _ := strconv.Atoi(scanner.Text())
	return a
}

func isPrime(n int) bool {
	for i := 2; i*i <= n; i++ {
		if n % i == 0 {
			return false
		}
	}
	return true
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		cnt := 0
		for i := 2; i <= n; i++ {
			if isPrime(i) {
				cnt++
			}
		}
		fmt.Println(cnt)
	}
}

C++: #include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<utility>
#include<sstream>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1005;
int dp[1000005];
bool leap[1000005];
int main()
{
	#ifdef LOCAL
	freopen("C:\\Users\\巍巍\\Desktop\\in.txt","r",stdin);
	//freopen("C:\\Users\\巍巍\\Desktop\\out.txt","w",stdout);
	#endif // LOCAL
	memset(leap,false,sizeof(leap));
	memset(dp,0,sizeof(dp));
    for(ll i = 2;i <= 999999;i++)
    {
        if(leap[i])continue;
        dp[i] = 1;
        for(ll j = i*i;j <= 999999;j = j + i)
            leap[j] = true;
    }
    for(int i = 1;i <= 999999;i++)dp[i] = dp[i] + dp[i - 1];
    int n;
    while(scanf("%d",&n) != EOF)
    {
        printf("%d\n",dp[n]);
    }
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
#define MAX_N 100001
int main(){
	int n;
	while(cin >> n){
		vector<int> vec;
		vector<int>::iterator it =vec.begin();
		for(int i=2;i<=n;i++){
			int flag=0;
			it =vec.begin();
			while(it!= vec.end()){
				if(i% *it==0){
					flag=1;
					break;
				}
				it++;
			}
			if(!flag)vec.push_back(i);
		}
		it =vec.begin();
		//while(it!= vec.end()){
		//	cout<<*it<<endl;
		//	it++;
		//}
		cout << vec.size()<<endl;
	}

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

int main(){
    vector<int> isprime;
    int n;
    cin >> n;
    for (int i = 0; i <= n; i++){
	isprime.push_back(1);
    }

    int prime = 0;
    for (int i = 2; i <= n; i++){
	if (isprime[i]){
	    prime++;
	    for (int j = 2; i * j <= n; j++) isprime[i*j] = 0;
	}
    }
    cout << prime << endl;
    
    return 0;
}

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

int a[999999];

int prime(int x) {
	if (a[x] == 1) return 1;
	else if (a[x] == 2) return 0;
	for (int i = 2; i < sqrt(x) + 1; i++) {
		if (x%i == 0) {
			a[x] = 2;
			return 0;
		}
	}
	return a[x]=1;
}
int main(){
	int n;
	while (scanf("%d", &n) != EOF){
		int count = 0;
		for (int i = 2; i <= n; i++) {
			if (prime(i))count++;
		}
		count++;
		if (n == 0)count = 0;
		if (n == 1)count = 0;
		if (n == 2)count = 1;
		printf("%d\n", count);
	}
	return 0;
}

C++: #include <iostream>
#define N 100000
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void)
{
    bool a[N+1];
    int prime[N], n;
    rep(i,N)
    {
        a[i] = true;
    }
    a[0] = a[1] = false;
    for(int i=2;i*i<=N;i++)
    {
        if(a[i])
        {
            prime[i] = prime[i-1] + 1;
            for(int j=i*i;j<N;j+=i)
                a[j] = false;
        }
        else
            prime[i] = prime[i-1];
    }

    while(scanf("%d", &n)!=EOF)
        printf("%d\n", prime[n]);
}

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

int main(){
  int input;
  while(scanf("%d",&input) != EOF){
    int count = 1;
    for(int i = 3;i <= input;i += 2){
      bool isPrime = false;
      for(int s = 3;s <= sqrt((float)i);s += 2){
        if(i % s == 0){isPrime = true; break;}
      }
      if(!isPrime)count++;
    }
    if(input == 2)printf("1\n");
    else if(input < 2)printf("0\n");
    else printf("%d\n",count);
  }

  return 0;
}

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

void sieve(int n, vector<int> &primes)
{
    vector<bool> v(n + 1, true);

    // check
    for (int i = 2, end = sqrt(n); i <= end; i++) {
        if (!i)
            continue;
        for (int j = i + i; j <= n; j += i)
            v[j] = false;
    }

    for (int i = 2; i <= n; i++)
         if (v[i])
            primes.push_back(i);
}

int main()
{
    vector<int> primes;
    vector<int> inputs;
    int i;

    // read all inputs
    for (int x; cin >> x;)
        inputs.push_back(x);

    // init sieve
    sieve(*max_element(inputs.begin(), inputs.end()), primes);

    for (auto x : inputs) {
        for (i = 0; i < primes.size(); i++) // find
            if (primes[i] == x) {
                i++;
                break;
            } else if (primes[i] > x)
                break;
        cout << i << endl;
    }

    return 0;
}

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];std::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);}}

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

//using namespace std;

int sosuu(int n);

int main(){
    int n = 0;
    int a[30]={0};
    int b[30]={0};
    int num = 0;
    int max =0;
    
    
    while(scanf("%d",&n)!=EOF){
        a[num]=n;
        if(max<n){
            max=n;
        }
        num++;
    }
    
    int temp = 0;
    for(int i=2; i<=max; i++ ){
        temp+=sosuu(i);
        for(int j=0; j<num; j++ ){
            if(i==a[j]){
                b[j]=temp;
            }
        }
    }
    
    for(int j=0; j<num; j++ ){
        printf("%d\n",b[j]);
    }
    
    
}

int sosuu(int n){
    if(n==2){
        return 1;
    }else{
        int temp=1;
        for(int i=0; i<n; i++){
            temp=temp*2;
        }
        if(temp%n!=2%n){
            return 0;
        }
        return 1;
    }
}

C++: #include<stdio.h>
#include<math.h>
int judge(int x)
{
	if (x == 2)
		return 1;
	for (int i = 2; i < sqrt(x) + 1; i++)
		if (x%i == 0)
			return 0;
	return 1;
}
int main()
{
	int a, num;
	while (scanf("%d", &a) != EOF)
	{
		num = 0;
		for (int i = 2; i <= a; i++)
			if (judge(i))
				num++;
		printf("%d\n", num);
	}
	return 0;
}

C++: #include<iostream>

using namespace std;



bool Prime(int n)
{
	if((n==1)||(n==0))
	{
		return false;
	}
	for(int i=2;i<=n-1;++i)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

using namespace std;

int main()
{
	int n,ans,flag;

	while(scanf("%d",&n)!=EOF){
		ans=0; 
		for(int i=2;i<=n;i++){
			flag=1;
			for(int j=2;j*j<=i;j++){
				if(i%j==0) {flag=0;break;}
			}
			if(flag) ans++;
		}
		cout<<ans<<endl;
	}

	return 0;
}

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

int main(){
  int a,j,cou;
  while(cin>>a){
    cou=0;
    for(int i=2;i<=a;i++){
      if(i==2){
	cou++;
	continue;
      }
      else if(i%2==0)continue;
      for(j=3;j*j<=i;j+=2)if(i%j==0)break;
      if(j*j>i)cou++;
    }
    cout <<cou<<endl;
  }
  return 0;
}

C++: #include <iostream>

bool divisible( int u, int v )
{
    return (u % v) == 0 ? true : false;
}

int num_divisors( unsigned int start, unsigned int end )
{
    if ( start == end ) return 1;
    return divisible( end, start ) + num_divisors( start+1, end );
}

int no_of_divisor( unsigned int n )
{
    return num_divisors( 1, n );
}

bool is_prime( unsigned int n )
{
    return (no_of_divisor(n) == 2);
}

int count_prime( unsigned int n )
{
    int count = 0;
    for ( unsigned int i = 1; i <= n; ++i )
    {
        if ( is_prime(i) ) ++count;
    }
    return count;
}

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