Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

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

func main() {
	for scanner.Scan() {
		n := nextInt()
		cnt := 0
		for i := 2; i <= n; i++ {
			if isPrime(i) {
				cnt++
			}
		}
		fmt.Println(cnt)
	}
}

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;
}

C++: 
//  test.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;


int main(){
    long j,s[1000000],d=1,i,n,k;
    
    for(i=2;i<1000000;i++){
        if(s[i]==0){
            
            for(j=2;j*j<i;j+=2){
                if(j%i==0)
                    break;
                if(j==2)
                    j=1;
            }
            
            if(j*j>=i){
                d++;
                for(k=2;k*i<1000000;k++){
                    s[k*i]=-1;
                }
            }
        }
        s[i] = d;
    }
    
    while(EOF != scanf("%ld",&n)){
        printf("%ld\n",s[n]-1);
    }
    
    
    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


const int Max=10000000;
bool prime[Max];
int main(void){
    int in;
    for(int i=0;i<Max;i++)prime[i]=true;
    prime[1]=false;
    for(int i=2;i<Max;i++){
        if(prime[i]){
            for(int s=i*2;s<=Max;s+=i)prime[s]=false;
        }
    }
    while(cin>>in){
        int cnt=0;
        for(int i=1;i<=in;i++){
            if(prime[i])cnt++;
        }
        cout << cnt << "\n";
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
	bool isprime[1000000];
	for (int i = 0; i < 1000000; i++)
		isprime[i] = 1;
	for (int i = 2; i < 1000; i++) {
		if (!isprime[i]) continue;
		for (int j = i * i; j < 1000000; j += i)
			isprime[j] = 0;
	}
	int n;
	while (cin >> n) {
		int ans = 0;
		for (int i = 2; i <= n; i++)
			if (isprime[i])
				ans++;
		cout << ans << endl;
	}
}

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

using namespace std;

int main()
{
	vector<long long int>D(1000001 , 1);
	D[0] = 0;
	D[1] = 0;
	for(long long int i = 2; i <= sqrtl(1000001); i++)
	{
		if(D[i])
		{
			long long int j = 2;
			while(i*j < 1000001)
			{
				D[i*j] = 0;
				j++;
			}
		}
		D[i] += D[i - 1];
	}
	long long int n;
	while(cin >> n)cout << D[n] << endl;
	return 0;
}

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

int arr[1000000];

int main()
{
	int x, cnt, j, i = 3;
	arr[2] = 1;
	for (; i < 1000000; ++i) {
		cnt = 1;
		for (j = 2; j <= sqrt(i); ++j) {
			if (i%j == 0) {
				arr[i] = arr[i - 1];
				--cnt;
				break;
			}
		}
		arr[i] = arr[i - 1] + cnt;
	}
	while (cin >> x) {
		cout << arr[x] << endl;
	}
	return 0;
}

C++: #include<stdio.h>
int a[1000001];

int Func(int n) {
	if (n == 0)return 0;
	else return a[n] + Func(n - 1);
}

int main() {
	a[0] = 0;
	a[1] = 0;
	a[2] = 1;
	for (int i = 3; i <= 1000000; i++) {
		if (i % 2 == 0)a[i] = 0;
		else {
			int h = 1;
			for (int j = 3; j*j <= i && h == 1; j += 2) {
				if (i%j == 0)h = 0;
			}
			a[i] = h;
		}
	}
	int n;
	while (~scanf("%d", &n)) {
		printf("%d\n", Func(n));
	}
}