Go: package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	//"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	for sc.Scan(){
		n := nextInt()
		fmt.Println(calc(n))
	}
}

func calc(n int)int{
	// エラトステネスで数え上げる
	// 最初から999999まで用意しておいて入力のたびO(1)で出すのとどっちが速いのかはわからん
	eratos := make([]bool, n+1)
	c := 0
	for i:=2; i<len(eratos); i++{
		if eratos[i] == false{
			c++
			for j:=i*i; j<len(eratos); j+=i{
				eratos[j]=true
			}
		}
	}
	return c
}

func next()string{
	return sc.Text()
}

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

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int gcd( int, int );

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

	return true;
}

int main()
{
	int n, count = 0;

	while ( cin >> n )
	{
		for ( int i = 2; i <= n; i++ )
		{
			if ( isPrime( i ) )
			{
				count++;
			}
		}

		printf("%d\n", count );
	}

	return 0;
}

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

using namespace std;

int main(){
	int n,i,j,buf,cnt;

	while(cin >> n){
		cnt = 1;

		for(i=3;i<=n;i+=2){
			buf = (int)sqrt((double)i);

			for(j=3;j<=buf;j+=2){
				if((i % j) == 0){
					cnt--;
					break;
				}
			}

			cnt++;
		}

		cout << cnt << endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int N[3]; int C[3] = { 0, 0, 0 };

	int PRIME[168];

	int cnt = 1;

	PRIME[0] = 2;

	for (int i = 3; i <= 999; i++)
	{
		for (int j = 2; j <= (i - 1); j++)
		{
			if (i % j == 0)
			{
				goto Exit1;
			}
		}
		
		PRIME[cnt] = i; cnt++;

	Exit1:;
	}

	cin >> N[0] >> N[1] >> N[2];

	for (int i = 0; i < 3; i++)
	{
		for (int j = 2; j <= N[i]; j++)
		{
			for (int k = 0; k <= 167; k++)
			{
				if (j % PRIME[k] == 0 && j != PRIME[k])
				{
					goto Exit2;
				}
			}

			C[i]++;

		Exit2:;
		}
	}

	cout << C[0] << endl << C[1] << endl << C[2] << endl;

	return 0;
}

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

void setPrime(int *prime , int num)
{
	vector<int> prime_num;
	prime_num.push_back(2);
	prime[2] = 1;
	for (int i = 3; i < num; i++) {
		bool isPrime = true;
		for (int j = 0; j < prime_num.size(); j++) {
			if (i%prime_num[j] == 0)
				isPrime = false;
		}
		if (isPrime) {
			prime_num.push_back(i);
		}
		prime[i] == prime_num.size();
	}
}

int main()
{
	int prime[1000000];
	setPrime(prime, 1000000);
	int n;
	while (cin >> n) {
		cout << prime[n] << endl;
	}
	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;

vector<int> PrimeNumber;
int p = 0;

int f(int x){
	if (x == 2) {
		PrimeNumber.push_back(x);
		return 1;
	}
	for (int i = 0; i < PrimeNumber.size(); i++){
		if (x%PrimeNumber[i] == 0) return 0;
	}
	PrimeNumber.push_back(x);
	return 1;
}

int main(){
	long int n;
	int ans = 0;
	while (cin >> n){
		ans = 0;
		PrimeNumber.clear();
		for (int i = 2; i <= n; i++){
			ans += f(i);
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>

using namespace std;

bool array[1000000];
int main()
{
	int n;
	array[0] = true;
	array[1] = true;
	n = 1000000;
	for (int i = 2; i < n; i++) {
		if (array[i] == false){
			for (int j = i * 2; j < n; j += i) {
				array[j] = true;
			}
		}
	}
	while (cin >> n){
		int pri = 0;
		for (int i = 0; i <= n; i++){
			if (array[i] == false) {
				pri++;
			}
		}
		cout << pri << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main(){
	int n=0,m=0,o=0,f=0,c=0;

	while(cin>>n){
		c=0;

	for(o=2;o<=n;o++)
	{	f=0;
				cout<<o<<"o"<<endl;
		for(m=2;m<o;m++){
			if(o%m == 0){f++;
			
				cout<<m<<" m "<<endl;}

		};
		if(f==0){c++;};

	};
	cout<<c<<endl;
	};
 return 0;

}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	bool f;
	while(1){
	vector<int> array;
	cin >> n;
	if(cin.eof())return 0;
	for(int i=2;i<=n;i++){
		f=true;
		for(int j=0;j<array.size();j++)
		if(!(i%array[j])){
		f=false;
		continue;
	}
		if(f==true)array.push_back(i);
	}
	cout << array.size() << endl;
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
#define ll long long
typedef pair<int, int> P;

bool prime[100005];
void solve()
{
	REP(i, 100005)prime[i] = true;
	prime[0] = prime[1] = false;
	FOR(i, 2, (int)sqrt(100005))
	{
		if (prime[i] == true)
		{
			FOR(j, 2, (int)sqrt(100005)){
				if (prime[i*j] == true)prime[i*j] = false;
			}
		}
	}
}

int main()
{
	int n;
	while (cin >> n)
	{

		int ans = 0;

		solve();
		REP(i, n + 1){
			if (prime[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

const int N = 10000002;

int main(){
  int n,count = 0 ;
  vector<int> v(N,1) ;
  v[0] = 0, v[1] = 0;
  for(size_t i = 2; i < N-1;++i){
    if(v[i] == 1){
      for(size_t j = i*2; j < N-1;j+=i){
          v[j] = 0 ;
      }
    }
  }
  while(cin >> n){
    count = 0 ;
    for(size_t i = 2; i <= n;++i){
      if(v[i] == 1){
        ++count ;
      }
    }
    cout << count << endl;
  }
  return 0 ;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
// have you mooed today?
bool isprime(int& num)
{
    static int c;
    static int max;
    max = sqrt(num) + 2;
    if(num == 2) return true;

    for(c=2; c < max; c++)
        if(num % c ==0) return false;
    return true;
}

int main()
{
    int ans;
    int buff;
    while(cin >> buff);
    {
        ans  = 0;
        for(int d =2; d <= buff; d++)
        {
            if(isprime(d)) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

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

int is_prime (int N)
{
    if (N<2) return 0;

    int limit = (int) sqrt(N);
    for (int i=2; i<=limit; ++i)
    {
        if (N%i==0)
            return 0;
    }

    return 1;
}

int main ()
{
    int num, primes, t=0;

    while ((scanf("%d", &num) != EOF) && (t<=30))
    {
        ++t;
        primes = 0;

        for (int i=1; i<=num; ++i)
        {
            if (is_prime(i)) ++primes;
        }

        printf("%d\n", primes);
    }

    return 0;
}

C++: #include<iostream>
#include<string.h>
using namespace std;
int n,ans;
bool a[10005];
int main(){
	while(cin>>n){
		memset(a,true,sizeof(a));
		a[0]=false;
		a[1]=false;
		ans=0;
		for(int i=2;i<=n;i++){
			if(a[i])
				for(int j=2*i;j<=n;j+=i)
					a[j]=false;
		}
		for(int i=1;i<=n;i++)
			if(a[i]) ans++; 
		cout<<ans<<endl;
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
main(){
	int n,p[100000];
	for(int i=0;i<=100000;++i)p[i]=1;
	p[0]=0;p[1]=0;
	for(int i=2;i<=100000,i*i<100000;++i){
		for(int j=2;j<=100000;++j){
			if(p[i]==0)break;
			if(j%i==0 && i!=j)p[j]=0;
		}
	}
	while(cin>>n){
		int sum=0;
		for(int i=0;i<=n;++i)if(p[i]==1)++sum;
		cout<<sum<<endl;
	}
}