Go: package main

import "fmt"

func main() {
	const MAX = 1000000
	prime := make([]int, MAX, MAX)
	check := make([]int, MAX, MAX)
	count := make([]int, MAX, MAX)

	prime[0] = 1
	prime[1] = 1

	// prime init
	for i := 2; i < MAX; i++ {
		if check[i] == 1 {
			continue
		}

		if prime[i] == 0 {
			for j := i * 2; j < MAX; j += i {
				check[j] = 1
				prime[j] = 1
			}
		}
	}

	for i := 2; i < MAX; i++ {
		cnt := 0

		if prime[i] == 0 {
			cnt = 1
		}

		count[i] = count[i-1] + cnt
	}

	for {
		var input int
		inputCount, _ := fmt.Scanf("%d", &input)
		if inputCount != 1 {
			break
		}

		fmt.Println(count[input])
	}
}

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

using namespace std;

int sosuu(int n) {
    vector< int > list;
    for (int i = 2; i <= n; i++) {
        list.push_back(i);
    }
    int count = 0;
    int p;
    while (true) {
        p = list[count];
        count++;
        for (int i = 0; i < list.size(); i++) {
            if (list[i] % p == 0 && list[i] != p) {
                list.erase(list.begin() + i);
                i--;
            }
        }
        if (list.size() > sqrt(n)) break;
    }
    // for (int i = 0; i < list.size(); i++) {
    //     cout << list[i] << " ";
    // }
    // cout << endl;
    return list.size();
}

int main() {
    int a;
    while (!cin.eof()) {
        cin >> a;
        if (std::cin.fail()) break;
        cout << sosuu(a) << endl;
    }

    return 0;
}

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

int main()
{
	int n, i, j, k=1, wareru=0;
	int sosu[500000];
	sosu[0] = 2;
	for (i = 3; i < 1000000; i += 2)
	{
		wareru = 0;
		for (j = 3; j <= sqrt(i*1.0); j += 2)
		{
			if (i%j == 0)
			{
				wareru = 1;
				break;
			}
		}
		if (wareru == 0)
		{
			sosu[k++] = i;
		}
	}

	while (scanf("%d", &n) != EOF)
	{
		for (i = 0; (sosu[i] <= n) && (sosu[i] != NULL); i++);
		printf("%d\n", i);
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
   int s[10000], l, m, n, i, k, sum;
   sum = 0;
   for ( i = 1; i <= 1000000; i++ ) {
      s[i] = 0;
   }
   for ( k = 2; k <= 1000000; k++ ){
      if (s[k] == 0) {
         for ( l = 2; l <= 100000 / k; l++ ) {
            s[k * l] = 1;
         }
      }
   }
   while(scanf("%d", &n) != EOF){
      for(i = 1; i <= n; i++){
         if(s[i] == 0){
            sum++;
         }
      }
   printf("%d", sum);
   }
   return 0;
}

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

using namespace std;

int main(){
  int n, i, j, isFound, count;

  while(cin >> n){
    for(i=3, count=1; i<=n; i+=2){
      for(j=3, isFound=0; j<=sqrt(i); j+=2){
	if(i%j == 0){
	  isFound = 1;
	  break;
	}
      }
      if(isFound == 0) count++;
    }
    cout << count << endl;
  }

  return 0;
}

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

std::vector<bool> primes(1000000, true);

void sieve() {
  primes[0] = false;
  primes[1] = false;
  for (int i = 2; i < primes.size(); ++i) {
    if (!primes[i]) { continue; }
    for (int j = 2, m = i * j; m < primes.size(); m = i * ++j) {
      primes[m] = false;
    }
  }
}

int main() {
  sieve();

  int n;
  while (true) {
    if (scanf("%d", &n) != 1) { break; }
    int count = 0;
    for (int i = 0; i <= n; ++i) { if (primes[i]) { ++count; } }
    printf("%d\n", count);
  }

  return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int whether(int num);
int count(int num);

int main(){
    int n;
    
    while(~scanf("%d",&n)){
        cout <<count(n)<<endl;
    }
    
    return 0;
}

int whether(int num){
    int s=sqrt(num);
    int i;
    
    for(i=3; i<=s; i+=2){
        if(num%i==0){ return 0; }
    }
    
    return 1;
}

int count(int num){
    int a=1;
    if(num<2){ return 0; }
    if(num==2){ return 1; }
    for(int i=3; i<=num; i+=2){
        if(whether(i)){ a+=1; }
    }
    
    return a;
}

C++: //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

bool isPrime(int n){
	int upper = sqrt(n);
	if(n == 2) return true;
	if(n % 2 == 0 ) return false;
	for(int i=3; i<=upper; i=i+2){
		if(n % i == 0) return false;
	}
	return true;
}

int num_prime(int n){
	int counter = 0;
	for(int i=2; i<=n; i++){
		if(isPrime(i)) counter++;
	}
	return counter;
}


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

C++: #include<iostream>

using namespace std;

int main(){
        long long  n=1, j=0, arr[30];
//      while( n>0){
        long long count=1;
        cin >> n;
        if(n==1){
        count = 0;
        goto END;}
        if(n==2)
                goto END;
        for(int i=3; i<=n; i+=2){
                if(i == 3 || i == 5 || i == 7)
                        count++;
                if (i % 3 ==0 || i % 5 == 0 || i % 7 == 0)
                        continue;
                else
                        count++;
        }
        //      END:arr[j++] = count;
//}
        //for(int i=0; i<j; i++){
                END:cout << count << endl;
//}


        return 0;

}

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

int main(){
	int n[1000000]={0};
	int tmp=0,a;
	
	n[0]=1;
	n[1]=1;
	for(int i=2;i<1000000;i++){
		for(int j=2;i*j<1000000&&n[i]!=1;j++){
			n[i*j]=1;
		}
	}
	
	while(cin>>a){
		tmp=0;
		for(int i=0;i<=a;i++){
			if(n[i]==0) tmp++;
		}
		cout<< tmp << endl;
	}
	return 0;
}

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

using namespace std;

bool is_prime(const unsigned n);


int main(){
	int n;

	while(cin >> n){
		int ans=0;

		for(int number=2;number<=n;number++){
			if(is_prime(number))ans++;
		}
		printf("%d\n",ans);
	}


	return 0;
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: 
        case 1: return false;
        case 2: 
        case 3: return true;
    } 

    if(n%2 == 0) return false;
    if(n%3 == 0) return false;

    if(n%6 != 1 && n%6 != 5) return false;

    for(unsigned i=5;i*i<=n;i+=6){
        if(n%i     == 0) return false;
        if(n%(i+2) == 0) return false;
    }

    return true;}

C++: #include <cstdio>  
#include <iostream>  
using namespace std;  
int prime[1000005];  
bool is_prime[1000005];  
int seve(int n)  
{  
    int p=0;  
    for(int i=0;i<=n;i++)  
        is_prime[i]=true;  
    is_prime[0]=is_prime[1]=false;  
    for(int i=2;i<=n;i++)  
    {  
        if(is_prime[i])  
        {  
            prime[p++]=i;  
            for(int j=2*i;j<=n;j+=i)  
                is_prime[j]=false;  
        }  
    }  
    return p;  
}  
int main(void)  
{  
    int n;  
    while(scanf("%d",&n)!=EOF)  
    {  
        printf("%d\n",seve(n));  
    }  
    return 0;  
}

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

using namespace std;

int main(){
  
  int n;
  
  while(cin >> n){
    bool d[1000000];
    int ans = 0;
    
    for(int i = 1;i <= n;i++){
      d[i] = true;
    }
    d[1]  = false;
    
    for(int i = 1;i <= n;i++){
      if(d[i] == true){
	ans++;
	for(int j = 1;j*i <= n;j++){
	  d[i*j] = false;
	}
      }
    }
    
    printf("%d\n",ans);
  }
  
  return 0;
  
}

C++: #include <iostream>
using namespace std;
bool prime[1000000];
void sieve() {
    fill_n(prime, 1000000, true);
    for (int i=2; i<=1000; ++i) {
        if (prime[i]) {
            for (int j=i; i*j<1000000; ++j) {
                prime[i*j] = false;
            }
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    sieve();
    int n;
    while (cin >> n) {
        int cnt = 0;
        for (int i=2; i<=n; ++i) {
            if (prime[i]) {
                cnt ++;
            }
        }
        cout << cnt << "\n";
    }
    return 0;
}

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

C++: #include<iostream>
using namespace std;
main(){
int n;
    while(cin>>n){
        cout<<n<<endl; 
   }
}