Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		input := nextInt()
		fmt.Println(IsPrime(input))
	}
}

func IsPrime(num int) int {
	eratos := make([]bool, num+1)
	c := 0
	for i := 2; i < len(eratos); i++ {
		if eratos[i] == false {
			c++
			eratosCalc(i, eratos)
		}
	}
	return c
}

func eratosCalc(primeNum int, eratos []bool) {
	for i := primeNum * primeNum; i < len(eratos); i += primeNum {
		eratos[i] = true
	}
}

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

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

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

int prime[1000000];


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


void get_prime(int max_num) {
  int primecount = 1;
  prime[2] = primecount;
  for (int i = 3; i <= max_num; i += 2) {
    if (isPrime(i))
      prime[i] = ++primecount;
    else
      prime[i] = primecount;
  }
}


int main () {
  int ns[31];
  int i = 0, max_num;
  while (std::cin >> ns[i]) {
    max_num = std::max(max_num, ns[i]);
    if (ns[i] % 2 == 0)
      ns[i] --;
    i ++;
  }
  get_prime(max_num);
  for (int j = 0; j < i; j ++) {
    std::cout << prime[ns[j]] << std::endl;
  }
  return 0;
}

C++: #include<iostream>

#define LIM 1000000
using namespace std;

int main(){
  bool num_map[LIM];
  int in_num,prime_count;
  for(int i=0;i<LIM;i++){
    num_map[i]=1;
  }
  
  for(int i=2;i<LIM;i++){
    if(num_map[i]==1)
      for(int j=i*2;j<LIM;j+=i){
	num_map[j]=cout<<in_num<<endl<<endl;
	for(int i=2;i<=in_num;i++){
	  if(num_map[i]==1)
	    prime_count++;
	}
	cout<<prime_count<<endl;  
      }
    
  }
}

C++: #include<iostream>
#include<conio.h>
#include<cmath>    

using namespace std;

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

     for (int i=2; i<n; i++)
        for (int j=2; j*j<=i; j++)
        {
            if (i % j == 0)
                break;
            else if (j+1 > sqrt(i)) {
                cout << i << endl;
            }
        }

     return 0;
 }

C++: #include <iostream>
#include <vector>
 
using namespace std;
 
const int N = 1000000;
bool flag[N];
int num[N];
 
int main(){
	for(int i=2;i<N;i++) flag[i] = true;
	for(int i=2;i*i<N;i++){
		if(not flag[i]) continue;
		for(int j=i*i;j<N;j+=i){
			flag[j] = false;
		}
    }
    num[0] = 0;
    for(int i=1;i<N;i++){
        if(flag[i]){
            num[i] = num[i-1] + 1;
        }else{
            num[i] = num[i-1];
        }
    }
    int n;
    while(cin >> n){
        cout << num[n] << endl;
    }
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
    int n,i,j,z,x;
	
    
	while(scanf("%d",&n)!=EOF){
		for(i=2;i<=n;i++){
			z=0;
			for(j=2;j*j<=i;j++){
				if(i%j==0){
					z++;
					break;
				}
			}
			if(z==0){
				x++;
			}
		}
		printf("%d\n",x);
		x=0;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
bool prime(int n){
	for(int i=2;i<n;i++){
		if(n%i==0)return false;
	}
	return true;
}
int main(){
	int a,sum=0;
	while(cin>>a){
	for(int j=2;j<a;j++){
		if(prime(j))sum++;
	}
	cout<<sum<<endl;
	sum=0;
	}
}

C++: #include<iostream>
#include<math.h>
using namespace std;
int tim1(int n)
{
	if(n<2)
	return 0;
	if(n==2||n==3)
	return 1;
	if(n%2==0||n%3==0)
	return 0;
	for(int i=5;i<=sqrt(n);i=i+6)
	if(n%i==0||(n+2)%i==0)
	return 0;
	return 1;
	
}
int tim(int n)
{
	int d=0,i;
	for(i=2;i<=n;i++)
	{
		if(tim1(i)==1)
		d=d+1;
}
	return d;
}
int main()
{
	int a[100000],i,n;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>a[i];
	for(i=1;i<=n;i++)
	{
	tim(a[i]);
	cout<<tim(a[i])<<endl;
     }
}

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



int main(){
	int i , j , n , pn , cn=0;
	
	while(cin>>n){
		pn=1;
		for(i=3 ; i<=n ; i++){
			for (j=2 ; j<i ; j++){
				if (i%j==0) goto skip;
			}
			pn++;
			skip:;
		}
		if(n==0 || n==1 ) {
			cout << 0 << endl;
		} else {
			cout << pn << endl;
		}
		cn++;
		if(cn>=30) break;
	}
	return 0;
}

C++: #include<iostream>
#include<stack>
#include<math.h>
using namespace std;
int dp[999999];
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 < 999999; i++) {
		dp[i] = -1;
	}
	return;
}

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	bool prime[1000000];
	rep(i,1000000)prime[i]=true;
	prime[0]=prime[1]=false;
	for(long i=2;i<1000L;i+=1L){
		for(long j=i*2;j<1000000;j+=i){
			prime[j]=false;
		}
	}
	long n;
	while(cin>>n){
		long cnt=0;
		rep(i,n+1){
			if(prime[i])cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

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

bool isPrime(int a){
	int x = std::sqrt((double)a);
	for(;x>1;x-=2){
		if(a%x == 0)
			return false;
	}
	return true;
}

int countPrime(int a){
	int x = a,ans = 1;
	if(x%2==0)
		x--;
	for(; x>1; x-=2){
		if(isPrime(x))
			ans++;
	}
	return ans;
}

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

C++: #pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	memset(vis, 0, sizeof(vis));
	memset(prime, 0, sizeof(prime));
	prime[0] = prime[1] = 0;
	for (int i = 2; i*i <=MAX; i++){
		if (!vis[i]){
			prime[i] = 1;
			for (int j = i+i; j*j <=MAX; j += i){
				vis[j] = 1;
				prime[j] = 0;
			}
		}
	}
	int sum = 0;
	for (int i = 0; i <= MAX; i++){
		if (prime[i]){
			sum++;
		}
		amount[i] = sum;
	}
	int n;
	while (cin >> n){
		cout << amount[n] << endl;
	}
	return 0;
}

C++: #include<stdio.h>

int	main(){
	int	i,	k,	x,	cnt,	data[10000];
	for(i	=	2;	i	<=	10000;	i++){
		data[i]	=	1;
	}
	for(i	=	2;	i	*	i	<=	10000;	i++){
		if(data[i]){
			for(k	=	2	*	i;	k	<=	10000;	k	+=	i){
				data[k]	=	0;
			}
		}
	}
	while(1){
		cnt	=	0;
		scanf("%d",	&x);
		if(x	==	0)break;
		for(i	=	2;	i	<=	x;	i++){
			if(data[x]	==	1)cnt++;
		}
		printf("%d\n",	cnt);
	}
	return	0;
}

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

bool nonprime[1000000];

int main(){
	long i,j,n;
	for(i=2;i<=999999;i++){
		for(j=2;i*j<=999999;j++) nonprime[i*j]=1;
	}
	while(1){
		cin >> n;
		j=0;//j?????????????????¨?????????????????????
		for(i=2;i<=n;i++) if(!nonprime[i]) j++;
		cout << j << endl;
	}
	return 0;
}

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

int main(){
	int n,k,p[100000],s,i,j;
	k=1;
	p[0]=2;
	for(i=3;i<999999;i+=2){
		s=0;
		for(j=0;j<k;j++){
			if((i%p[j])==0){
				s++;
			}
		}
		if(s==0){
			p[k]=i;
			k++;
		}
	}
	
	while(cin >> n){
		for(i=0;n>=p[i];i++){
		}
		cout << i <<"\n";
	}
return 0;
}