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:
		return true
	case num < 2 || num%2 == 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 <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
using namespace std;
typedef long long int ll;

int main(){
    int n;
    while (cin >> n) {
        vector<ll> era(n+1,0);
        for (int i=1; i<era.size(); i++) {
            era[i]=i;
        }
        for (int i=2; i<era.size(); i++) {
            if (era[i]!=0) {
                int q = i+1;
                while (q<era.size()) {
                    if (era[q]%era[i]==0) {
                        era[q]=0;
                    }
                    q++;
                }
            }
        }
        int ans=-1;
        for (int i=1; i<=n; i++) {
            if (era[i]==i) {
                ans++;
            }
        }
        cout << ans <<endl;
    }
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<deque>
#include<algorithm>
using namespace std;
//#define int long long

signed main(){
        deque<int> primes{2};

        for(int i=3;i<1000000;i+=2){
                for(unsigned int j=0;j<primes.size();j++){
                        if(primes[j]*primes[j]>i){
                                primes.push_back(i);
                                break;
                        }
                        if(i%primes[j]==0){
                                break;
                        }
                }
        }

        int a;
        while( scanf("%d", &a) != EOF ){
                cout<<distance(primes.begin(), upper_bound(primes.begin(),primes.end(),a))<<endl;
        }

        //int n;
        //scanf("%lld",&n);
        //for(int i=0;i<n;i++){}

        return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
int a[1000000]{};
bool b[1000000]{};
a[1]=0;
int s=0;
for(int c=2;c<1000000;c++){
	if(!b[c]){
		s++;
		for(int d=c*2;c<1000000;d+=c)b[d]=true;
	}
	a[c]=s;
}
int k;
while(scanf("%d",&k)){
	printf("%d\n",a[k]);
}
}

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 1000005
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
#define ll long long
typedef pair<int, int> P;

bool prime[MAX_N];

void solve()
{
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	FOR(i, 2,(int)sqrt(MAX_N))
	{
		if (prime[i] == true)
		{
			FOR(j, 2, (int)sqrt(MAX_N)){
				if (prime[i*j] == true)prime[i*j] = false;
			}
		}
	}
}

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

		int ans = 0;

		solve();
		REP(i, n + 1){
			if (prime[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
	bool flag = false;
	int num, cou, i, j;
	
	while(cin >>num){
		cou = 0;
		for(i = 3; i < num; i+= 2, flag = false){
			for(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 <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main() {
	const int MAX_V = 100000;
	int prime[MAX_V+1];
	int i, k, v;
	for(i = 2; i <= MAX_V; i++) {
		prime[i] = 1;
	}
	for(i = 2; i*i <= MAX_V; i++) {
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0;
			}
		}
	}
	scanf("%d", &v);
	while (v != 0){
		int count = 0;
		for(i=0;i<=v;i++){
			int isprime = prime[i];
			if(isprime) count ++;
		}
		printf("%d\n",count);
		scanf("%d", &v);
	}
	return 0;
}

C++: #include<stdio.h>
	   const int MAX_V = 1000000;
	   int prime[MAX_V+1];
	   int sum[MAX_V+1];
	   int main(){
	   	int i,k,v,m=2,cnt=0;
	   	for(i=m;i<=MAX_V;i++){
	   		prime[i]=1;
	   	}
	   	for(i=m;i*i<=MAX_V;i++){
	   		if(prime[i]){
	   			for(k=2*i;k<=MAX_V;k+=i){
	   				prime[k]=0;
	   			}
	   		}
	   	}
	   	for(i=0;i<MAX_V+1;i++){
	   	 sum[i+1]=sum[i]+prime[i];
	   	}
	   	while(scanf("%d",&v)!=EOF){
	   	 printf("%d\n",sum[v+1]);
	   	}
	   	return 0;
	   }

C++: #include<stdio.h>
int prime(int x)
{
    int i,j,k,l=0;
    for(k=2;k<=x;k++)
    {
        int flag=0;
        for(i=2;i*i<=k;i++)
        {
            if(k%i==0)
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
        {
            l+=1;
        }
    }
        return l;
}

int main()
{
    int n,m;
    while(scanf("%d",&n))
    {
        m=prime(n);
        printf("%d\n",m);
    }
    return 0;
}

C++: #include <cstdio>
#define max_n 999999
int prime[max_n];
bool is_prime[max_n+1];
int main(){
    for(int i=0; i<max_n; i++){
        is_prime[i]=true;
    }
    int p = 0;
    is_prime[1]=false;
    is_prime[0]=false;
    for(int i=2;i<max_n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<max_n;j+=i)is_prime[j]=false;
        }
    }
    int n;
    while(~scanf("%d",&n)){
        int ans = 0;
        for(int i =0; i<max_n; i++){
            if(prime[i]>n){
                ans = i;
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

C++: #include <stdio.h>

const int MAX_V = 10000;
int prime[MAX_V+1];

void init(){
    int i, k, v;
    for(i=2; i<=MAX_V; i++){
        prime[i] = 1;
    }
    for(i=2; i*i<=MAX_V; i++){
        if(prime[i]){
            for(k=2*i; k<=MAX_V; k+=i){
                prime[k]=0;
            }
        }
    }   
}

int isprime(int n){
    return prime[n];
}

int main(){
    init();
    int num;
    while(1){
        int count=0;
        scanf("%d", &num);
        for(int i=2; i<=num; i++){
            if(isprime(i)==1)
                count++;
        }
    printf("%d\n", count);
    }
    return 0;
}

C++: #include <iostream>

using namespace std;
int main(void){
    int n;
    int count;
    int prime[1000000];
    int i,j;
    while(cin>>n){
        count=0;
        fill(prime,prime+1000000,0);
        prime[0]=prime[1]=1;
        for(i=2;i<=n;i++){
            if(prime[i]==0){
                count++;
                for(j=2*i;j<=n;j+=i){
                    prime[j]=1;
                }
            }
        }
        cout<<count<<endl;
    }
    return(0);
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
  vector<bool> p(1000000, true);
  p[0] = false;
  p[1] = false;
  for (int i = 2; i <= 1000; i++) {
    if (p[i]) {
      for (int j = i * 2; j < 1000000; j += i) {
        p[j] = false;
      }
    }
  }

  int n;
  while (cin >> n) {
    int res = 0;
    for (int j = 0; j <= n; j++)
      if (p[j]) res++;
    cout << res << endl;
  }
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int N;
    bool prime[100010]={0};
    prime[1]=1;
    for(int i=2;i*i<100000;i++){
        if(prime[i]==0){
            for(int j=i;j<100000;j+=i){
                prime[j]=1;
            }
        prime[i]=0;
        }
    }
    while(~scanf("%d",&N)){
        int cnt=0;
        for(int i=1;i<=N;i++){
            if(prime[i]==0)cnt++;
        }
        cout<<cnt<<endl;
    }
    return 0;
}