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>

using namespace std;
bool IsPrime[1000000];
int PrimeNum[1000000];

void PrimeCalc()
{
	for(int i = 0; i < 1000000; ++i)
	{
		IsPrime[i] = true;
	}
	int count = 0;
	PrimeNum[0] = PrimeNum[1] = 0;
	for(int i = 2; i < 1000000; ++i)
	{
		if(IsPrime[i])
		{
			++count;
			PrimeNum[i] = count;
			for(int j = 2 * i; j < 1000000; j += i)
			{
				IsPrime[j] = false;
			}
		}
		else
		{
			PrimeNum[i] = PrimeNum[i - 1];
		}
	}
}

void solve()
{
	PrimeCalc();
	int n;
	while(cin >> n)
	{
		cout << PrimeNum[n] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<stdio.h>

int main(void)
{
	int data,i,j,k=0,l=0,kai=0,s[100000]={0};

	while(scanf("%d",&data) != EOF)
	{
		if(data<=1)
		   kai[k]=0;
		else
		{
			for(i=2;i<=data;i++)s[i]=i;

		    i=2;
			while(i*2<data)
			{
			  if(s[i] != 0)
			  {  
				 j=2;
				while(j*i<=data)
				{
					s[j*i]=0;
					j+=1;
				}
			  }
			  i+=1;
			}

			
			for(i=2;i<=data;i++)
			{	
				if(s[i]!=0)
				{
					kai+=1;
				}
			}
		}
		printf("%d",kai);
		kai=0;
	}

  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<windows.h>
#include<conio.h>
#include<String>
#include<time.h>
#include<math.h>

using namespace std;
int c = 0;
int i = 1;
unsigned long long a = 0;
unsigned long long b = 0;
unsigned long long sosuu[100000] = { 0 };
char fire = 0;
int pattara = 0;

int sub(int c) {

	
	
	/*while(i>-1)*/
	for (int i = 2; i<=c; i++){
		/*for (int z = 0; z < a;z++){*/
		for (int q = 1; q <= sqrt(i); q++) {
			sosuu[pattara] = i;
			if (sosuu[pattara] % 2 == 0 && sosuu[pattara]!= 2) {
				break;
			}
			if (sosuu[pattara] % q == 0) {
				b += 1;
			}

		}

		if (b == 1) {
			/*fire = _getch();*/
			pattara++;
			
		}
		b = 0;
		/*i++;*/
	}

	
	return 0;
}


int main(){
	while (scanf("%d", &c) != EOF){

		sub(c);
		cout << pattara << endl;
		pattara = 0;
	}


}

C++: #include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn= 999999+5;
ll prime[maxn];
int main()
{
	ll cnt=0;
	for(ll i=2;i<maxn;++i)
	{
		if(!prime[i])
		{
			prime[i]=++cnt;
			for(ll j=i*i;j<maxn;j+=i)
			{
				prime[j]=1;
			}
		}
		else
		{
			prime[i]=prime[i-1];
		}
	}
	ll n;
	while(~scanf("%lld",&n))
	{
		printf("%lld\n",prime[n]);
	}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>
#include <iostream>

using namespace std;

int sum[100100];
int bprime[1000100];

int main() {
  memset(bprime, true, sizeof(bprime));
  bprime[0] = bprime[1] = false;
  for (int i = 2; i < 1000000; i++) {
    if (!bprime[i]) { continue; }
    for (int j = i + i; j < 1000000; j += i) {
      bprime[j] = false;
    }   
  }
  sum[0] = 0;
  for (int i = 1; i < 1000000; i++) {
    sum[i] = sum[i - 1] + (bprime[i] ? 1 : 0); 
  }
  int n;
  while (scanf("%d", &n) > 0) {
    printf("%d\n", sum[n]);
  }
}

C++: #include <stdio.h>

int main(){
	int n,m,o,p;
	
	while(scanf("%d", &n) != EOF){
		p = 0;
		
		for( ; n > 1; n--){
			o = 0;
			
			for(m = n-1; m > 1; m--){
				if(n % m){
					o++;
				}else{
					break;
				}
			}
			
			if(o != (m-1)){
				p++;
			}
		}
		
		printf("%d\n", p);
	}
	
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main(){
	
	int i,N,count= 0;
	bool flag;

	while (cin >> N) {
		for (i = 2; i <= N; i++) {
			flag = 0;
			for (int j = 2; j < i; j++) {
				if (i%j == 0) {
					flag = 1;
					break;
				}
			}
			if (flag == 0)
				count++;
		}
		cout << count << endl;
		count = 0;
	}

	return 0;
}

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

int whether(int num);
int count(int num);

int main(){
	int n;
	int a;
	clock_t c, d;

	while(scanf("%d",&n) != EOF){
	a = count(n);
	printf("%d\n",a); 
}

	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;
	int i;
	if(num <2){ return 0; }
	for(i=3; i<=num; i+=2){
		a += whether(i);
	}

	return a;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    FOR(i,3,100000){
	bool flg = true;
	REP(j,primes.size()) if(i % primes[j] == 0 ) flg = false;
	if(flg) primes.PB(i);
    }

    int n;
    while(true){
	cin >> n;
	int res = upper_bound(ALL(primes),n) - primes.begin();
	cout << res << endl;
    }

    return 0;
}

C++: #include<stdio.h>
int p[100000],l;
void prime(){
    int i,j,k;
    p[0]=2;
    l++;
    for(i=3;i<=999999;i+=2){
        k=1;
        for(j=0;j<l;j++){
            if(p[j]*p[j]>i)break;
            if(i%p[j]==0){
                k=0;
                break;
            }
        }
        if(k==1){
            p[l++]=i;
        }
    }
}
int main(void){
	int i,a,cnt=0;
	prime();
	while(scanf("%d",&a)!=EOF){
	    for(i=0;p[i]<=a;i++);
	    printf("%d\n",i);
	}
	return 0;
}

C++: #include "iostream"
using namespace std;
int main()
{
	int n,i,j,count=0;
	cin>>n;
	for(i=2;i<=n;i++)
	{
		for(j=2;j<=i/2;j++)
		{
			if(i%j==0)
				break;
		}
		if(j>i/2)
			count++;
	}
	cout<<count;
}

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

int main(){
	bool flag = false;
	int num, cou;
	
	while(cin >>num){
		cou = 0;
		for(int i = 3; i < num; i+= 2, flag = false){
			for(int j = 3; j < sqrt(num); j += 2){
				if(i % j == 0){
					flag = true;
					break;
				}
			}
			if(flag == false) cou++;
		}
		cout <<cou + 2<<endl;
	}
	
	return 0;
}

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


bool isPrime(int I)
{
	int b = sqrt (I*1.0) + 1;
	for(int i = 2; i < b; i ++){
		if(I % i == 0)
			return false;
	}
	return true;
}
void printPrime(int N)
{
	int total = 0;
	for(int i = 2; i <= N; i ++)
	{		
		if(isPrime(i) == true){
			total ++;
		}
	}
	cout<<total<<endl;
}


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

C++: #include <iostream>
#include <cmath>
#define Even(n) n%2
using namespace std;

void count_Prime(int n);
bool IsPrime(int num);


int main()
{
	int Data;

	while (cin >> Data)
	{
		count_Prime(Data);
	}

	return 0;
}

void count_Prime(int n)
{
	int counter = 0,  i = 0;
	for (i = 2; i <= n; ++i)
	{
		if (IsPrime(i))
			counter++;
	}

	cout << counter << endl;

}

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // ??¶??°????????????????????????

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// ?´???°??§?????????
			return false;
		}
	}

	// ?´???°??§??????
	return true;
}