Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

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

C++: #include <iostream>

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

C++: #include<stdio.h>
 
#define MAX 1000000
 
int main(){
    char prime[MAX];
    int num, i, j, ans;
 
    for(i = 0; i < MAX; i++)
    {
        prime[i] = 1;
    }
    prime[0] = prime[1] = 0;
    for(i = 2; i < (MAX/2); i++)
    {
        if(prime[i])
        {
            for(j = 2*i; j < MAX; j += i)
            {
                prime[j] = 0;
            }
        }
    }
     
    while(scanf("%d", &num) != EOF)
    {
        ans = 0;
         
        for(i = 3; i <= num; i+=2)
        {
            ans += prime[i];
        }
         
        printf("%d\n", ans);
    }
 
    return 0;
}

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

int main()
{
	long int n,m;
	while(cin>>n){
		long int i;
		int number[10000]={0};
		int ans=0;

		for(i=0;i<n;i++){
			if(number[i]==0){
				ans++;
				for(m=i;m<n;m+=i){
					number[i]=1;
				}
			}
		}
		cout<<ans<<endl;
	}
}

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

int main() {
	vector<int> p;
	int n;
	p.push_back(2);
	for(int i=3;i<999999;i++){
		for(int j=0;;j++){
			if(i%p[j]==0)
			break;
			if(i<p[j]*p[j]){
			p.push_back(i);
			break;
			}
		}
	}
	while(cin >> n){
		int i=0;
		while(n>=p[i]){
			i++;
		}
		cout << i << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

bool P[1000000];

int main() {
    int n, ans;
    while (cin >> n) {
        fill(P, P + n + 1, true);
        P[0] = P[1] = false;
        for (int i = 0; i * i <= n; i++) {
            if (P[i]) {
                for (int j = i + i; j <= n; j += i) {
                    P[j] = false;
                }
            }
        }
        ans = 0;
        for (int i = 0; i <= n; i++) if (P[i]) ans++;
        cout << ans << endl;
    }
}

C++: #include<stdio.h>
#include<math.h>
#include<cmath>
#include<vector>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define eps 1e-8
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) (a<b?a:b)
#define ll long long
#define INF 9223372036854775807
int prime[1000005];
bool isprime[10000005];
int num;
int main()
{
    for(int i=2;i<1000005;i++)
    {
        if(isprime[i])
            continue;
        prime[num++]=i;
        for(int j=2*i;j<1000005;j+=i)
        {
            isprime[j]=1;
        }
//        if(i<100)
//            printf("%d\n",prime[num-1]);
    }
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int ans=upper_bound(prime,prime+num,n)-prime;
        printf("%d\n",ans);
    }
    return 0;
}