Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2 || num == 5:
		return true
	case num < 2 || num%2 == 0 || num%5 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

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

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

C++: #include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
 
 
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
const int INF = 100000000;
const double EPS = 0.0000001;
typedef pair<int,int> P;

int n;

bool isPrime[100003];

void solve() {
	int ans=0;
	rep(i,n+1) if(isPrime[i]) ans++;
	cout<<ans<<endl;
}

void init() {
	rep(i,100003) isPrime[i]=true;
	isPrime[0]=isPrime[1]=false;

	for(int i=2;i<100003;i++) {
		if(isPrime[i]) {
			for(int j=i+i;j<100003;j+=i) isPrime[j]=false;
		}
	}


}

int main() {
	init();
	while (cin>>n)
	{
		if(n==0) return 0;
		solve();

	}
}

C++: #include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(){
	int n,a[9];
	a[0]=9592;
	a[1]=17984;
	a[2]=25997;
	a[3]=33860;
	a[4]=41538;
	a[5]=49098;
	a[6]=56543;
	a[7]=63951;
	a[8]=71274;
	while(cin>>n){
		int count=0;
		int i=0;
		while(true){
			if((i+1)*100000<=n)
				count=a[i];
			else
				break;
			i++;
		}
		if(n<100000){
			count=1;
			for(int j=3;j<=n;j++){
			bool t=false;
			for(int k=2;k<1+(double)sqrt((double)j);k++){
				if(j%k==0)
					t=true;
			}
			if(t==false)
				count++;
		    }
		}
		else{
		    for(int j=(i)*100000+1;j<=n;j++){
			    bool t=false;
			    for(int k=2;k<1+(double)sqrt((double)j);k++){
				    if(j%k==0)
				        t=true;
			    }
			    if(t==false)
				    count++;
		    }
		}
		cout<<count<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	
	long long int k,p[100000];
	long long int n;
	p[0]=2;
cin>>n;

		if(n<0){
			break;
		}
	k=0;
	int r=(int)sqrt((float)n);
	for(int i=3;i<=r;i++){
		for(int j=0;j<k+1;j++){
			if(i%p[j]==0){
				break;
			}else if(j==k){
				k++;
				cout<<i<<endl;
				p[k]=i;
			}
		}
	}
	long long int r_k=k;
	for(;r<n;r++){
		for(long int i=0;i<=r_k;i++){
			if(r%p[i]==0){
				break;
			}else if(i==r_k){
				k++;
				cout<<r<<endl;
			}
		}
	}
	if(k!=0&&k!=1){
		k+=1;
		cout<<k<<endl;
	}else{
		cout<<k<<endl;
	}
}

C++: #include<iostream>
using namespace std;
#define N 1000000
int main(){
	bool prime[N+1] = {0};
	prime[1] = 1;
	for(int i = 2; i * i <= N; i++){
		if(prime[i] == 0){
			for(int j = i; j <= N; j+=i){
				prime[j] = 1;
			}
			prime[i] = 0;
		}
	}
	int n;
	while(cin >> n){
		int cnt = 0;
		for(int i = 1; i <= n; i++){
			if(!prime[i])cnt++;
		}
		cout << cnt << 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 <cmath>
using namespace std;
int prime(int);
int main(){
    int a,sum;
    int b[999999];
    b[0]=0;
    for(int i=1;i<999999;i++){
        b[i]=prime(i);
    }
    while ( cin >> a){
        sum =0;
        for (int i=1;i<a;i++){
            sum +=b[i+1];
        }
        cout << sum << endl;
    }
}
int prime(int x){
    if(x==1)
        return 0;
    if(x==2)
        return 1;
    for (int i=2;i<=sqrt(x)+1;i++){
        if(x%i==0)
            return 0;
    }
    return 1;
}

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

int setPrimeNumberCount(int n) {
    int count = 0;
    bool primeFlag = true;
    
    if(n >= 2) {
        count++;
    }
    
    for(int i = 3; i <= n; i+=2) {
        for(int j = 3; j < i; j+=2) {
            if(i % j == 0) {
                primeFlag = false;
                break;
            }
        }
        if(primeFlag) {
            count++;
        }
        primeFlag = true;
    }
    return count;
}

int main(void) {
    int n;
    int count = 0;
    
    while(cin >> n) {
        count = setPrimeNumberCount(n);
        cout << count << endl;
        count = 0;
    }
    return 0;
}

C++: #include <stdio.h>
#include <math.h>
int sosuu(int x){
    int n,m,sosuu;
    sosuu=x-2;
    for(n=2;n<x;n++){//nは素数を調べる。入力された数字まで１からスライドしていく。
        for(m=2;m<n;m++){//mはnが素数かどうか調べる。素数かどうかをnより小さい数字で数えていく。2からなのは2から素数だから。1はふくめない。
            if(n%m==0){//素数じゃなかったら、つまり割り切れてしまったら。
                sosuu--;
            }
           
            if(n%m==0) break;
        }
    }
    if(x==1||x==0) sosuu=0;
    return sosuu;
}

int main ( void ) {
    int s,result;
    scanf("%d",&s);
        result = sosuu(s);
        printf("%d\n",result);
    
    return 0;
}

C++: #include"iostream"
#include"math.h"
#define ll long long 
using namespace std;
int snt(ll n)
{
 ll i;
 ll m;
 if(n == 2 || n == 3)
  return 1;
 if (n == 1||n % 2 == 0||n % 3 == 0)
  return 0;
 m = (int)sqrt(n);
 for(i=5;i<=m;i=i+6)
  if(n % i == 0 || n % (i+2) == 0) return 0;
 return 1;
}
ll lam(ll n)
{
	ll d=0;
	for(ll i=2;i<=n;i++)
	{
		if(snt(i))
		d++;
	}
	return d;
}
int main()
{
	ll n;
	do
	{
		cin>>n;
		cout<<lam(n);
		cout<<endl;
	}while(1);
}

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

using namespace std;

int main()
{
    int n, flag, c = 1;
    long long a[99999];
    for(int i=2; i<=99999; i++)
    {
        flag = 0;
        for(int j=2; j<=sqrt(i); j++)
        {
            if(i % j == 0)
            {
                flag = 1;
            }
        }
        if(flag == 0)
        {
            a[i] = 1;
        }
        else
        {
            a[i] = -1;
        }
    }

    while(scanf("%d",&n) != EOF)
    {
        int m = 0;
        for(int i=2; i<=n; i++)
        {
            if(a[i] == 1)
            m++;
        }

        cout<<m<<endl;
    }
}

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

bool prime(int m){
	if(m < 2)return false;
	if(m == 2)return true;
	if(m%2 == 0)return false;
	for(int i = 3; i*i <= m; i += 2){
		if(m%i == 0)return false;
	}
		return true;
}

int main(){
	int n;
	
	while(cin >> n){
		int a=0;
		for(int i = 1; i <= n; ++i){
			if(prime(i))++a;
	}
		cout << a << '\n';
	}
}

C++: #include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>


/*
	HOME-  Volume0-0009
	Submit Statistics
	 
	PCK 2003
	Prime Number
	Time Limit : 1 sec, Memory Limit : 32768 KB
	English version is here
	Prime Number

	6 ÈºÌ³Ì® n ðüÍµAn ÈºÌfª¢­Â é©ðoÍ·évOðì¬µÄº³¢B½¾µAfÆÍ 1 Æ©ª©gÅµ©èØêÈ¢³Ì®Ì¤¿ 1 ðÌ¼¢½àÌð¢¢Ü·Bá¦Î 10 ÈºÌfÍA2, 3, 5, 7 Å·B
	Input

	¡Ìf[^Zbgª^¦çêÜ·Bef[^ZbgÉ n ªPsÉ^¦çêÜ·BüÍÌÅãÜÅµÄº³¢B
	Output

	ef[^Zbg²ÆÉAn ÈºÌfÌÂðPsÉoÍµÄº³¢B
	Sample Input

	10

	Output for the Sample Input

	4

*/

using namespace std;


int main()
{
	string s;
	
	while (getline(cin, s))
	{
		int n;
		sscanf(s.c_str(), "%ld", &n);
		
		vector<int> v;
		v.reserve(n);
		
		for (int i = 0; i <= n; i++)
		{
			v.push_back(1);
		}
		v[0] = 0;
		v[1] = 0;
		
		for (int i = 2; i <= n; i++)
		{
			for (int k = i + 1; k <= n; k++)
			{
				if (0 == (k % i))
				{
					v[k] = 0;
				}
			}
		}
		
		int x = 0;
		for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
		{
			if (*it)
			{
				x++;
			}
		}
		
		printf("%d\n", x);
	}

	return 0;
}