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 <stdio.h>
#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {

	int n;
	int *k;
	
	while (cin >> n) {
		int counter = 0;
		k = (int *)malloc(sizeof(int) * n);
		if (k == NULL) {
			exit(0);
		}
		k[0] = 1;
		for (int i = 1; i < n; i++) {
			k[i] = 0;
		}

		for (int i = 1; i < n; i++) {
			if (k[i] == 0) {
				/*for (int j = 1; j < i; j++) {
					if (k[j] == 0) {
						if ((i+1) % (j+1) == 0) {
							k[i] = 1;
							break;
						}
					}
				}*/
				if (k[i] == 0) {
					for (int t = 2; t <= n/(i+1); t++) {
						k[(i+1)*t-1] = 1;
					}
				}
			}
		}

		for (int i = 1; i < n; i++) {
			if (k[i] == 0) {
				counter++;
			}
		}

		cout << counter << endl;

		free(k);
	}

	return 0;
}

C++: /* All men have limits. They learn what they are and learn
   not to exceed them, I ignore mine. -Batman           */

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

void wakwaw(int *x) { 
     x[1] = 0; 
     x[2] = 1; 
     for (int i = 3; i <= 1000000; i += 2) 
         x[i] = 1; 
 
 
     for (int i = 3; i <= 1000; i += 2) { 
         if (x[i] == 0) 
             continue; 
         for (int j = 2; i * j <= 1000000; j++) 
            x[i * j] = 0; 
     } 
 
 
     for (int i = 3; i <= 1000000; i++) 
         x[i] += x[i-1]; 
 } 
 
 
 int main() { 
 
 
     int *arr = new int[1000001]; 
     wakwaw(arr); 
 
 
     int n; 
     while (cin >> n) { 
         cout << arr[n] << endl; 
     } 
 
 
     return 0; 
 }

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vi prime_count;
void sieve(int max){
    int count = 0;
    vector<bool> table(max + 1, true);
    table[0] = false;
    prime_count.push_back(0);
    table[1] = false;
    prime_count.push_back(0);
    for(int i = 2; i <= max; i++){
        if(table[i]){
            count++;
            for(int j = 2; i * j <= max; j++){
                table[i * j] = false;
            }
        }
        prime_count.push_back(count);
    }
}

int main(){
    int n;
    sieve(10000);
    while(cin>>n){
        cout << prime_count[n] << endl;
    }
}

C++: #include <iostream>
#include <memory.h>
using namespace std;
int main()
{
	bool prime[1000010];
	memset(prime,1,1000010);
	prime[0]=prime[1]=0;
	int i,j,n,sum;
	for (i=2;i<1000000;i++)
	{
		if (prime[i])
		{
			for (j=2;i*j<1000000;j++)
			{
				prime[i*j]=false;
			}
		}
	}
	while(cin>>n)
	{
		sum=0;
		for(i=2;i<=n;i++)
		{
			sum+=prime[i];
		}
		cout<<sum<<endl;

	}	
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	
	long int n,f,k,i;
	int count;
	bool chk;
	while(scanf("%d",&n)!=EOF){
		count=0;
		for(i=2;i<=n;i++){
		
			chk=0;
			f=i/2;
			k=2;
		
			while(f>=k){
				if((i%k)==0){
					chk=true;
					break;
				}
				k++;
			}
		
			if(chk==false){
				count++;
			}
		}
		cout<<count<<endl;
	}
}

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

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

	}

}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int arr[1000000]={0};
bool isPrime(int n){ 
    if(n<2)
        return false;
    for(int i=2; i*i<=n; i++){
        if(n%i==0)
            return false;
    }   
    return true;
}
void arra(int n, int m){ 
    int c=0;
    if(n>m){
        int memo=m;
        m=n;
        n=memo;
    }   
    for(int i=n+1; i<=m; i++){
        if(isPrime(i)){
            c++;
            //arr[i]=arr[n]+c;
        }   
        arr[i]=arr[n]+c;
    }   
    //arr[m]=arr[n]+c;
}
int main(){
    int n, m=0;
    while(cin>>n){
        if(arr[n]==0){
            arra(n, m); 
        }   
        cout<<arr[n]<<endl;
        m=max(n, m); 
    }   
    return 0;
}

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

bool isprime(int number, std::vector<int> const& primeset)
{
	int maxprime = static_cast<int>(std::sqrt(static_cast<float>(number)));

	typedef std::vector<int>::const_iterator Iter;
	Iter primesetlimit = std::upper_bound(primeset.begin(), primeset.end(), maxprime);
	for (Iter p = primeset.begin(); p != primesetlimit; ++p) {
		if (number % *p == 0) {
			return false;
		}
	}
	return true;
}

int resolve(int number)
{
	if (number < 2) {
		return 0;
	}
	if (number == 2) {
		return 1;
	}
	std::vector<int> primesetExceptTwo;
	for (int i = 3; i <= number; i += 2) {
		if (isprime(i, primesetExceptTwo)) {
			primesetExceptTwo.push_back(i);
		}
	}
	return static_cast<int>(primesetExceptTwo.size()) + 1;
}

int main()
{
	int input;
	while (std::cin >> input) {
		std::cout << resolve(input) << std::endl;
	}

	return 0;
}

C++: #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

int main(){
  int a[1000010];
  rep(i,1000010) a[i]=1;
  
  rep(i,1000000){
    if(i<2){
      a[i]=0;
      continue;
    }
    if(i==2){
      a[i]=1;
      continue;
    }
    else if(i%2==0){
      a[i]=0;
      continue;
    }
    
    for(int j=3;j*j<=i;j+=2){
      if(i%j==0){
        a[i]=0;
        continue;
      }
    }
  }
  
  int dp[1000010];
  dp[0]=0;
  for(int i=1;i<1000009;i++){
    if(a[i]) dp[i]=dp[i-1]+1;
    else dp[i]=dp[i-1];
  }
  
  int n;
  while(cin>>n){
    cout<<dp[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 = log2(N);
	while (cin >> N){
		int sum =0;
		cout << N*p << endl;
	}
	return 0;
}

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

int main()
{
    bool notPrime[1000000]={false};
    notPrime[0]=notPrime[1]=true;
    for (unsigned i=3; i<1000000; i+=2) {
        if (!notPrime[i]) {
            for (unsigned j=2; i*j<1000000; j++) {
                notPrime[i*j]=true;
            }
        }
    }
    for (unsigned n, count; cin >> n; cout << count << endl) {
        count=0;
        if (n>=2) {
            count++;
            for (unsigned i=3; i<=n; i+=2) {
                if (!notPrime[i]) {
                    count++;
                }
            }
        }
    }
    return 0;
}