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<vector>
using namespace std;

class prime{
	int cnt;
	vector<int> p;
public:
	prime();
	int num(int n);
};

prime::prime(){
	p.clear();
}

int prime::num(int n){
	if(n<2)return 0;
	if(n==2)return 1;
	p.push_back(2);
	int c;
	cnt=1;
	for(int i=3;i<=n;i+=2){
		c=0;
		for(int j=0;j<(int)p.size();j++){
			if(i%p[j]==0){
				c++;
				break;
			}
		}
		if(c==0){
			p.push_back(i);
			cnt++;
		}
	}
	return cnt;
}

int main()
{
	int n;
	while(cin >> n){
		prime pr;
		cout << pr.num(n) << endl;
	}
	return 0;
}

C++: #include <stdio.h>
bool used[1000005];int RideBack[79000],last=0;
int bin_search(int val) {int left=0,right=last-1,ans=0;while (left<=right) {int center=(left+right)>>1;if (RideBack[center]>val) right=center-1;else left=center+1,ans=left;} return ans;}
int main() {
    int i;for (i=2;i<=1000000;used[i++]=true);
    for (i=2;i<=1000;i++) if (used[i]) for (int j=i*i;j<=1000000;j+=i) used[j]=false;
    for (i=2;i<=1000000;i++) if (used[i]) RideBack[last++]=i;
    while (scanf("%d",&i)!=EOF) printf("%d\n",bin_search(i));return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;


// cin >>
// cin <<
bool isPrime(int x){
	if(x==2) return true;
	if(x<2||x%2==0) return false;
	int i=3;
	while(i<=sqrt(x)){
		 if (x%i==0)return false;
		i= i+2;
	}
	return true;
}
int main(){
	int in[30]={};
	int out=0;
	for(int i=0;i<30;i++) cin >>in[i];
	for(int i=0;i<30;i++){
		if(in[i]==0){
			break;
		}else{
			out=0;
			for(int j=0;j<in[i]+1;j++){
				if(isPrime(j)==true){
					out++;
				}
			}
			cout <<out<<endl;
		}
	}
	
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#define INF 999999
using namespace std;

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

		int a[INF] ;
		
		rootn = sqrt(n)+1;
	
		for (int i = 2; i <= rootn; i++)
		{
			if (a[i]==0)
			{
				for (int j = i+1; j <= INF; j++)
				{
					if (a[j] == 0 && j%i == 0)
					{
						a[j] = 1;
					}
				}
			}
		}
		cout << "a" << endl;
		for (int i = 2; i <= n; i++)
		{
			if (a[i]==0)
				++ans;
		}
		cout << ans << endl;
	}
			
	return 0;
}

C++: #include <iostream>
using namespace std;
 
int main() {
	int N;
	bool is_prime[1000000];
	is_prime[0]=0; is_prime[1]=0;
	for(int i=2;i<1000000; i++){
		is_prime[i]=1;
	}
 
	for(int s=2; s<1000000; s++){
		if(is_prime[s]==1){	
		for(long long i=s*s; i<1000000; i+=s){
		is_prime[i]=0;	
 
		}
		}
	}
 
	while(cin >> N){
 
		int ans=0;
		for(int i=2; i<N+1; i++){
			ans+=is_prime[i];
		}
		cout << ans <<endl;
 
	}
return 0;
}

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

int main(){
	int n;
	while(cin>>n){
		int ans=0;
		for(int m=2;m<=n;m++){
			for(int i=2;i<=sqrt(m);i++){
				if(m%i==0){
					ans++;
					break;
				}
			}
		}
		cout<<n-ans-1<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stack>
#include<math.h>
using namespace std;
int dp[100000000];
void shokika();
int main() {
	int n, ans = 0, i, count = 0, count2 = 0, insq;
	double sq;
	bool bo=false;
	shokika();
	while (cin >> n) {
		for (i = 2; i <= n; i++) {
			if (dp[i] == 1) {
				ans++;
				bo = true;
			}
			else {
				bo = false;
			}
			//sq = sqrt(i);
			//insq = (int)sq;
			for (int j = 2; j <= i; j++) {
				if (bo == true) {
					break;
				}
				else if (bo == false && dp[i] != -1) {
					count = 0;
					break;
				}
				/*
				if ( (i % 2 == 0 || i % 3 == 0 || i % 5 == 0 || i % 7 == 0 || i % 11 == 0)) {
					count = 0;
					break;

				}
				*/
				if (i%j == 0) {
					count++;
				}
				if (count >= 2) {
					break;
				}
				/*
				else {
					cout << i <<" "<<count<< endl;
				}
				*/

			}
			if (bo == true) {
				continue;
			}
			if (dp[i] == -1) {
				dp[i] = count;
			}
			if (dp[i] == 1) {
				//	cout << i << endl;
				ans++;
			}
			count = 0;
		}
		cout << ans << endl;
		ans = 0;
	}

	/*
	for (int i = 1; i < n; i++) {
		if (n%i == 0) {
			count++;
		}
		if (count >= 2) {
			count = 0;
			continue;
		}
		else  {
			ans++;
		}
	}
	cout << ans << endl;
	ans = 0;
}
*/
	return 0;
}
void shokika() {
	for (int i = 0; i < 100000000; i++) {
		dp[i] = -1;
	}
	return;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;

const int SIZE = 1000000;
bool is_prime[SIZE];
vector<int> primes;
int main()
{
	fill(is_prime, is_prime+SIZE, true);
	for (int i = 2; i < SIZE; ++i)
	{
		if (is_prime[i])
		{
			for (int j = 2*i; j < SIZE; j += i)
				is_prime[j] = false;
			primes.push_back(i);
		}
	}

	int n;
	while (scanf("%d", &n) != EOF)
		printf("%d\n", upper_bound(primes.begin(), primes.end(), n) - primes.begin());

	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <vector>
#include <map>

int main() {
	int a;
	while (std::cin >> a) {
		int nSum = 0;
		for (int i = 2;i <= a;i++) {
			int flag = 0;
		for (int j = 2;j < i;j++) {
			if (i%j == 0) {
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			nSum += 1;
		}
	}
		std::cout << nSum << std::endl;
	}
	return 0;
}

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

int Era(int N) {
	int prime_num = 0;
	int* array = new int[N + 1];
	for (int i = 2; i < N + 1; i++) {
		array[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (array[i]) {
			for (int j = 0; i*(j + 2) <= N; j++) {
				array[i*(j + 2)] = 0;
			}
		}
	}
	for (int i = 2; i < N + 1; i++) {
		if (array[i])prime_num++;
	}
	return prime_num;
}

int main() {
	int num;
	while (cin >> num) {
		cout << Era(num) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> prime;
prime.push_back(2);//ôðÈ­½ß2ÍÅÉüêÄ¨­
bool flag;
for(int x=3;x<=n;x+=2){
flag=true;
for(int y=0;prime[y]*prime[y]<=x;y++){
if(!(x%prime[y])){
flag=!flag;
break;
}
}
if(flag)prime.push_back(x);
}
cout << prime.size() << endl;
return 0;
}

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

int main()
{
	vector<int> pcount;
	int prime[10000];
	int j, k, x, num,count=0;
	while (cin >> num){
		prime[0] += 2;
		x = 1;
		k = 1;
		while (prime[k-1] <= num)
		{
			x += 2;
			j = 0;
			while (j < k && x % prime[j] != 0)j++;
			if (j == k)
			{
				prime[k++];
				count++;
			}
		}
		pcount.push_back(count);
		count = 0;
		break;
	}
	for (int i = 0; i < pcount.size(); i++)
	{
		cout << pcount[i] << endl;
	}
	return 0;
}

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

int main(void) { 
	int A[1000000];
	for(int i = 0; i < 1000000; i++){
		A[i] = 1;
	}
	A[0] = A[1] = 0;
	for(int i = 2; i < 1000; i++){
	    if(A[i] == 1){
    		for(int j = 2; j < 500; j++){
                A[i * j] = 0;
		    }
	    }
	}
	int n;
	while(cin >> n){ 
		int COUNT = 0;
		for(int i = 1; i <= n; i++){
            COUNT += A[i];
		}
		cout << COUNT << endl;
	}
	return 0; 
}