Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := 2; j < MAX/i; j++ {
                                if i * j < MAX {
                                        primes[i*j] = 0
                                }
                        }
                }
        }
}

C++: #include <cstdio>
#include <algorithm>

using namespace std;

const int a[] = {1, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 121, 127, 131, 137, 139, 143, 149, 151, 157, 163, 167, 169, 173, 179, 181, 187, 191, 193, 197, 199, 209};

int func(int v)
{
	int b = v / 210;
	int c = -1;

	int left=0, right=48;
	do{
		int mid = (left+right)/2;
		if(a[mid] == v-b*210){
			c = mid;
			break;
		}else if(a[mid] < v-b*210)
			left = mid + 1;
		else
			right = mid - 1;
	}while(left<=right);

	return c == -1 ? -1 : b*48 + c;
}

int main(void)
{
	unsigned char* eratos = new unsigned char[28572000];
	fill(eratos, eratos+28572000, 0);
	eratos[0] = 1;

	int cnt = 4;
	int i, j, k, n;
	scanf("%d", &n);
	if(n==1) cnt = 0;
	else if(n==2) cnt = 1;
	else if(n<=4) cnt = 2;
	else if(n<=6) cnt = 3;
	else{
		for(i=0; i*210<n; ++i){
			for(j=0; j<48; ++j){
				int v = i*210 + a[j];
				int pos;
				if(v>n)
					break;
				pos = func(v);
				if(!((eratos[pos/8]>>(pos%8))&1)){
					++cnt;
					for(k=v*2; k<=n; k+=v){
						int p = func(k);
						if(p != -1)
							eratos[p/8] |= 1<<(p%8); 
					}
				}
			}
		}
	}

	printf("%d\n", cnt);
	delete[] eratos;

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int n;
int main(){
	while(cin>>n){
		int sum=0;
		for(int i=2;i<=n;i++){
			for(int j=2;j<=sqrt(i);j++){
				if(i%j==0){
					goto loop;
				}
			}
			sum++;
			loop:;
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

int pnum[350000];
int main(){
	int n,data[30] = {0};
	int pcorsole = 0,dcorsole = 0;
	int i,j;
	int root;
	while(scanf("%d",&n) != EOF){
		for(i = 2;i <= n;i++){
			root = (int)sqrt((double)i);
			for(j = 0;j < pcorsole && pnum[j] < root;j++){
				if(i%pnum[j] == 0)
					break;
			}
			if(j == pcorsole || pnum[j] >= root){
				pnum[pcorsole] = i;
				pcorsole++;
				data[dcorsole]++;
			}
		}
		dcorsole++;
	}
	for(i = 0;i <= dcorsole;i++){
		printf("%d\n",data[i]);
	}
	return 0;
}

C++: #include<iostream>
main(){
	int i,j,n,p[1000000];
	std::cin>>n;
	for(i=2;i<=n;i++)
		p[i]=1;
	for(i=2;i<n;i++)
		for(j=2;i*j<=n;j++)
			p[i*j]=0;
	j=0;
	for(i=2;i<n;i++)
		j+=p[i];
	std::cout<<j<<std::endl;
}

C++: #include <iostream>

using namespace std;

int main(){
	int n=0,m=0,o=0,f=0,c=0;

	while(cin>>n){
		c=0;

	for(o=2;o<=n;o++)
	{	f=0;
		for(m=2;m<o;m++){
			if(o%m == 0){f++;}

		};
		if(f==0){c++;};

	};
	cout<<c<<endl;
	};
 return 0;

}

C++: #define scanf_s scanf
#include <stdio.h>
#include <iostream>
using namespace std;
#define MAX 200
int main(void)
{
	int a, b, sum, cou = 0;
	while (scanf_s("%d %d", &a, &b) != EOF) {
		sum = a + b;
		while (1) {
			if (sum <= 0) break;
			sum /= 10;
			++cou;
		}
		printf("%d\n", cou);
		cou = 0;
	}
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

template< typename T >
map<T,int> prime_factorization(T n) {
	map<T,int> res;
	for(T i=2;i*i<=n;i++) {
		while(n%i==0) {
			res[i]++;
			n/=i;
		}
	}
	if(n!=1) res[n]=1;
	return res;
}

vector<bool> eratosthenes(int n) {
	vector<bool> is_prime(n+1,true);
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i*i<=n;i++) {
		if(is_prime[i]) {
			for(int j=2*i;j<=n;j+=i) {
				is_prime[j]=false;
			}
		}
	}
	return is_prime;
}

vector<int> prime_list(int n) {
	vector<int> res;
	auto is_prime=eratosthenes(n);
	for(int i=0;i<=n;i++) {
		if(is_prime[i]) {
			res.push_back(i);
		}
	}
	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll n;
	while(cin>>n) {
		auto ls=prime_list(n);
		cout<<(int)ls.size()<<endl;
	}

}

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;
	int n;
	cin >> n;
	for (int i = 2; i<=n; i++){
		if (!vis[i]){
			
			prime[i] = 1;
			for (int j = i+i; j<=n; j += i){
				vis[j] = 1;
				prime[j] = 0;
				
		}
	}
	int sum = 0;
	for (int i = 2; i <= n; i++){
			if (prime[i]){
				sum++;
			}
		}
		cout << sum << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a[999999]={0,0,1,2},n,k=0,count=2;
	for(int i=4;i<999999;i++){
		for(int j=2;j*j<=i;j++){
			if(i%j==0)k++;
		}
		if(k==1)count++;
		a[i]=count;
		k=0;
	}
	while(cin>>n)cout<<a[n]<<endl;
	return 0;
}

C++: #include <stdio.h>
 
int main()
{
	int sieve[10001] = {'0'};
	int i,j,n,t;
	
  sieve[0] = sieve[1] = 1;
  for (int i = 2; i * i <= 10000; i++){
    
    for (int j = i*2; j <= 10000; j += i){
      sieve[j] = 1;
    }
  }
  while(scanf("%d", &n) != EOF){
  	t = 0;
  for(int i=1; i<=n ;i++){
  	if(sieve[i] == 0)t++;
  }
  printf("%d\n", t);
  }
  return (0);
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	vector<bool>mp(1e6,true); mp.front()=mp.at(1)=false;
	for(int i=2;i*i<1e6;++i){
		if(!mp.at(i))continue;
		for(int j=i*i;j<1e6;j+=i){
			mp.at(j)=false;
		}
	}
	vector<int>sum(1e6); sum.front()=0;
	for(int i=1;i<1e6;++i){
		sum.at(i)=sum.at(i-1)+mp.at(i);
	}
	int n;
	while(cin>>n){
		cout<<sum.at(n)<<"\n"s;
	}
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
#define size 20000000
using namespace std;
int find_prime(int n)
{
    int count =0;
    bool *numberList=new bool[size+1];
    for(unsigned long i=3;i<=sqrt(n);i+=2)
    {
        for(unsigned long j=i;i*j<=n;j+=2)
            numberList[i*j]=true;
    }
    for (unsigned long i=3;i<=n;i+=2)
    {
        if(!numberList[i])
            count++;
    }

    return count;

}
int main ()
{
    int n;
    while((scanf("%d",&n))!=EOF)
    {
        if(n==1||n==0)
            printf("0\n");
        else if(n==2)
            printf("1\n");

        else
        {
        int v=0;
        v=find_prime(n);
        printf("%d\n",v+1);
        }
    }
    return 0;
}

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

int main() {
	int n,ans=0,prime[1000000];
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;++i){ prime[i]=1; }
	for(int i=2;i<1000000;++i){
		if(prime[i]==1) {
			++ans;
			if(i<1000) for(int j=i*i;j<1000000;j+=i) prime[j]=0;
		}
		prime[i]=ans;
	}
	while(scanf("%d",&n) != EOF) { printf("%d\n",prime[n]); }
	return 0;
}