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 <math.h>
#include <stdlib.h>
#define N 999999
char num[N];
void furui(){
  int i, divide;
  for(i = 0; i < N; i++){
    num[i] = 1;
  }
  num[0] = 0;
  num[1] = 0;
  for(divide = 2; divide <= sqrt(N); divide++){
    if(num[divide] == 0) continue;
    for( i = 0; i < N; i++){
      if(i % divide == 0){
        num[i] = 0;
      }
    }
    num[divide] = 1;
  }
}

int main(void){
  int c, i, j;
  char buf[7];
  long int n;
  long int count = 0L;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0; ;i++){
      c = getchar();
      if(c == EOF || c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    n = atol(buf);
    for(i = 1; i <= n; i++){
      if(num[i] == 1) count++;
    }
    printf("%ld\n", count);
    if(c == EOF) break;
  }
  return 0;
}

C++: #include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> prime;
void init(){
	for(int i=2;i<999999;i++){
		bool isprime=true;
		for(vector<int>::iterator p(prime.begin());p!=prime.end();p++){
			if(i%*p==0){
				isprime=false;
				break;
			}
		}
		if(isprime){
			prime.push_back(i);
		}
	}
}
int main(){
	int n;
	init();
	while(cin>>n){
		cout<<lower_bound(prime.begin(),prime.end(),n)-prime.begin()+1<<endl;
	}
	return 0;
}

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

bool isp[max];
int ans[max]={};

void sieve(){
	for(int i=0;i<max;i++)isp[i]=true;
	for(int i=2;i<max;i++){
		if(isp[i]){
			ans[i]++;
			for(int j=2*i;j<max;j+=i)isp[j]=false;
		}
	}
	for(int i=1;i<max;i++)ans[i]+=ans[i-1];
	return;
}

int main()
{
	int n;

	sieve();
	while(cin>>n)cout<<ans[n]<<endl;

	return 0;
}

C++: #include<iostream>
 
using namespace std;
 
int main(){
  static bool cmp[1000000]={true};
  static int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
    cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1]+!cmp[i];
  }
  for(int n;cin>>n;n++){
    cout<<npr[n]<<endl;
  }
  return 0;
}

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

int prime(int data){
	int i;
	if(data%2 == 0){
		return 0;
	}
	for(i = 3;i < sqrt(data);i+=2){
		if(data%i == 0){
			return 0;
		}
	}
	return 1;
}

int main(void){
	int data,cnt=0,i;
	while(std::cin >> data){
		if(data > 1)cnt = 1;
		for(i=3;i<=data;i++){
			if(prime(i)){
				cnt++;
			}
		}
		std::cout << cnt << std::endl;
	}
}

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

int main()
{

	int n;
	while (cin >> n) {
		int C = 0;
		bool prime[1000000] = { 0 };
		// 0????´???°
		prime[1] = 1;
		prime[2] = 0;

		for (int j = 2; j * j <= n; j++) {
			if (prime[j] ==0) {
				for (int k = 2; k*j <= n; k++) {
					prime[j*k] = 1;
				}
			}
		}
		for (int i = 1; i <= n; i++) {
			if (prime[i] == 0)
				C++;
		}
		cout << C << endl;
	}
	return 0;
}

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

int main(void)
{
    int count=0;
    int i=1;
    int n=1;
    int number;
    int a[30]={0};
    int j=0;
    // insert code here...
    while (cin >> number){
        while (n <= number){
            if(n == 1) {n++; continue;}
            while (i <= n) {
                if(i == 1) {i++; continue;}
                if(i == n) count++;
                if(n % i == 0) break;
                i++;
            }
            n++;
            i=1;
            
        }
        i=1;
        n=1;
        j++;
        a[j] = count;
    }
    
    for(int i=0;i<j;i++){
        cout << a[j] << endl;
    }
    return 0;
}

C++: /*
	大号水?，拿来?手
*/
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;

int Find_Number (int x)
{
	int cnt = 0;
	for (int i=2;i<=x;i++)
	{
		bool flag = false;
		for (int j=2;j<=sqrt((double)i);j++)
		{
			if ( i % j == 0)
			{
				flag = true;
				break;
			}
		}
		if (flag == false )
		{
			cnt++;
		}
	}
	return cnt;
}

int main ()
{
	int N;
	scanf("%d",&N);
	cout<<Find_Number (N)<<endl;
	return 0;
}

C++: #include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cctype>
#include <stdlib.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <iterator>

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define ss(ch) scanf("%s",ch)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define ps(ch) printf("%s",ch)
#define NL printf("\n")
#define debug(x) printf("wow %d !!\n",x)

typedef long long LL;

using namespace std;

bool array[1000010];
int ans[1000010];
int main()
{
    int i,j;
    array[1]=1;
    for(i=2; i*i<=1000005; i++)
    {

        if(!array[i])for(j=i*i; j<=1000005; j=j+i)array[j]=1;
    }
    int cnt=0;
    rep(i,1000005)
    {
        if(array[i]==0)cnt++;
        ans[i]=cnt;
    }
    int n;
    while(si(n) !=EOF)
    {
        pi(ans[n]);
        NL;
    }
    return 0;
}

C++: #include<cstdio>
#include<cstring>
int main(){
 int n,cnt=0;
 scanf("%d",&n);
 int a[n+1];
 memset(a,-1,sizeof(int)*(n+1));
 for(int i=2;i<=n;i++){
 if(a[i]==-1){ cnt++;
 for(int j=i;j<=n;j=j+i) a[j]=0;}
}
return 0;
}

C++: #include<iostream>
#include<math.h>
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;
}

void add(int* primes, int& now,int prime) {
	primes[now] = prime;
	now++;
}

int main() {
	int num;
	int primes[1000]; int now = 0;
	while (cin >> num) {
		add(primes, now, Era(num));
	}
	for (int i = 0; i < now; i++) {
		cout << primes[i] << endl;
	}
	return 0;
}

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

using namespace std;

int prime(int n);

int main(){
  vector<int> inp;
  int num,pri;					
  int i=0;

  while(cin>>num){
if(num>999999)break;
    if(num <= 1)inp.push_back(0);
    else{
      pri = prime(num);
      inp.push_back(pri);
    }
    i++;
  }
  int j = 0;
  while(j < i){
    cout<<inp[j]<<endl;
    j++;
  }
}

int prime(int num){
  int count=0;
  bool judge=0;
  for(int i = 2; i <= num; i++){
    judge =1;
    for(int j= 2; j < i; j++){
      if(i%j == 0)judge =0;
    }
    if(judge==1)count = count +1; 
  }
  return count;
}

C++: #define _USE_MATH_DEFINES
#include <iostream> 
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std; 
int main(){
	int N;
	while (cin >> N){
		int sum =0;
		for(int i=2; i<=N; i++){
			int flag = 1;
			for(int q = 2;q <= sqrt(i);++q){
				if(i % q == 0){
					flag = 0;
				}
			}
			sum += flag;
		}
		cout << sum << endl;
	}
	return 0;
}