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>
int main(void){
int x,i,t=0;
while(scanf("%d",&x)!=EOF){
for(i=2;i*i<x;i++){
if(x%i==0)
break;
t++;
}
printf("%d\n",t);
}
return 0;
}

C++: #include<stdio.h>
int main ()
{
int p,n,m,cou;m=0;cou=0;p=3;
while(scanf("%d",&n)!=EOF)
{
for(int i=3;i<=n;i+=2){
for(int k=3;k*k<i;k++){
if(i%k==0){m++;break;}}
if(m==0)cou++;
m=0;
}
if(n==2)cou=1;
else if(n==1)cou=0;
else cou++;
printf("%d\n",cou);
cou=0;
}
return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int ma=1e7;
  vector<bool>sosu(ma,1);
  sosu[0]=sosu[1]=0;
  for(int i=4;i<ma;i+=2)sosu[i]=0;
  for(int i=3;i<ma;i+=2)
    for(int j=i*3;j<ma;j+=i*2)sosu[j]=0;
  int in;
  while(cin>>in){
    int co=0;
    loop(i,2,in+1)if(sosu[i])co++;
    cout<<co<<endl;
  }
}

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

void setPrimesUnder(int n, bool *p){
    if(n > 2){
        setPrimesUnder(sqrt(n), p);
        for(int i=2; i<=sqrt(n); i++){
            if(!p[i])                       // if i is not a prime
                continue;                   // i++
            for(int j=2; j<=1000000/i; j++) // if i is a prime
                p[i*j] = false;             // the other multiples of i is not a prime
        }
    }
    else{
        p[0] = false;
        p[1] = false;
        p[2] = true;
    }
}

int main(){
    int n;
    bool p[1000000];
    for(int i=0; i<1000000; i++)
        p[i] = true;
    setPrimesUnder(1000000, p);
    
    while(std::cin >> n){
        int count = 0;
        for(int i=0; i<=n; i++){
            if(p[i])
                count++;
        }
        std::cout << count << std::endl;
    }
    return 0;
}

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

bool IsPrime(int m){
    if(m==1){
        return(0);
    }else if(m==2){
        return(1);
    }else if(m%2==0){
        return(0);
    }else{
        for(int i=3;i*i<=m;i+=2){
            if(m%i==0)return(0);
        }
        return(1);
    }
}

int main(){
    int n;
    int r[30];
    bool p[1000000];
    for(int i=1;i<=999999;i++){
        p[i]=IsPrime(i);
    }
    for(int i=0;i<30;i++){
        r[i]=0;
    }
    int j=0;
    while(cin>>n){
        for(int i=1;i<=n;i++){
            r[j]+=p[i];
        }
        cout<<r[j]<<endl;
        j++;
    }
    return(0);
}

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[1000000];
	int count;
	int maxin=0;
	c[0]=c[1]=0;
	for(i=2;i<1000000;i++){
		c[i]=1;
	}

	while(scanf("%d",&n)!=EOF){
		if(n>maxin){
			maxin=n;
		}
		count=n;

		
		for(i=0;i*i<=n;i++){
			if(c[i]==1){
				for(j=i+1;j<=n;j++){
					if(j%i==0){
						c[j]==0;
						count--;
					}
				}
			}
		}

		printf("%d",count);


	}





	return 0;
}

C++: #include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int n;
bool is_prime[100000];
int prime[100000];

int main(int argc, char const* argv[])
{
	fill(is_prime, is_prime+100000, true);
	is_prime[0] = false;
	is_prime[1] = false;
	int res = 0;
	for(int i = 2; i < 100000; i++){
			if(is_prime[i]){
					res++;
					for(int j = 2; j * i < 100000; j++){
							is_prime[j * i] = false;
					}
			}
			prime[i] = res;
	}
	while(cin >> n){
			cout << prime[n] << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long double lb;

const int INF=1<<27;
const int MOD=(int)1e9+7;

int main(void)
{
	int n[30];
	bool po[1000001]={false};
	bool prime[1000001]={0};
	po[0]=true;
	po[1]=true;
	int cnt;
	while(cin>>n[cnt]) cnt++;

	int m=0;
	rep(i,cnt) m=max(n[i],m);

	for(int j=2;j<=m;j++){
		if(po[j]){
			prime[j]=prime[j-1];
			continue;
		}
		prime[j]=prime[j-1]+1;
		for(int k=j;k<=m;k++) po[k]=true;
	}

	rep(i,cnt) cout << prime[i] << endl;

        return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int data=1,i,j,s[1000000],x;

	while((scanf("%d\n",&data)) != EOF)
	{
		for(i=0;i<data;i++){
			s[i]=1;}
		x=0;
		if(data<=1){
			printf("%d\n",0);}
		else
		{
			for(i=2;i<=data/2;i++)
				for(j=i*2;j<data;j+=i)
				    s[j]=0;		
		for(i=0;i<data;i++)
			x+=s[i];
		printf("%d\n",x);
		}
	}
  return 0;
}

C++: #include<iostream>
int r(int n){if(n<2)return 0;else if(n==2)return 1;if((n&1)==0)return 0;for(int i=3;i*i<=n;i+=2)if(n%i==0)return 0;return 1;}int main(){int n,s,i,p;for(;!(std::cin>>n).eof();){for(i=p=0;i++<=n;)p+=r(i);printf("%d\n",p);}}

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

bool dec(int value) {
  for (int j = 3; j <= value/2; j += 2) {
    if (value % j == 0) { return false; }
  }
  return true;
}

int main() {
  int n;
  while (cin >> n) {
    int count = 0;
    if (n >= 2) { count++; }
    for (int i = 3; i <= n; i += 2) {
      if (dec(i)) { count++; } 
    }
    cout << count << endl;
  }
  return 0;
}

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

bool isPrime(int);

int main() {
	int n, p;
	while (cin >> n) {
		p = 2;
		if (cin.eof())
			return 0;
		for (int i = 5; i <= n; i++) {
			if (isPrime(i))
				p++;
		}
		cout << p << endl;
	}
	return 0;
}

bool isPrime(int x) {
	for (int j = 5; j * j <= x; j += 2) {
		if (x % j == 0)
			return false;
	}
	return true;
}

C++: //艾氏&#31579;法
#include <iostream>
using namespace std;
#define MAX_N 999999+16

int prime[MAX_N];//保存素数
bool is_prime[MAX_N + 1];//第几个数字是不是素数
int sieve(int n){
	int p = 0;
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;
	//其&#23454;可以&#20026;sqrt(n)
	for (int i = 2; i <= n; ++i){
		if (is_prime[i])
			prime[p++] = i;
			for (int j = i * i; j <= n; j += i)
				is_prime[j] = false;
	}
	return p;
}
int main(){
	
	int n;
	while (cin >> n){
		cout << sieve(n) << endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
	int i,j,n;
	bool judge[1000000]={0};
	
	for(i=3; i<1000000; i++)if(i % 2 == 0)judge[i] = 1;
	
	for(i=3; i<500000; i+=2){
		if(judge[i]==0){
			for(j=i*2;j<1000000;j+=i){
				if(j % i == 0){
					judge[j]=1;
				}
			}
		}
	}
	
	for(;;){
		int count=0;
		scanf("%d",&n);
		if(n==0)break;
		for(i=3;i<=n;i+=2){
			if(judge[i]==0)count++;
		}
		printf("%d\n",count+1);
	}
	return 0;
}