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++: #pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int(i)=(l); (i)<(r); ++(i))
#define rep(i,n) rer(i,0,n)
#define gnr(i,l,r) for(int (i)=(r)-1; (i)>=(l); --(i))
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

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

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  auto pri=prime_table(1000000);
  V(int)psum(1000000,0);
  rer(i,1,1000000){
    psum[i]=psum[i-1]+pri[i];
  }
  while(cin>>n)pri(psum[n]);
}

C++: #include <cstdio>

using namespace std;

int n;
int euler(int n){
     int res=n,a=n;
     for(int i=2;i*i<=a;i++){
         if(a%i==0){
             res=res/i*(i-1);
             while(a%i==0) a/=i;
         }
     }
     if(a>1) res=res/a*(a-1);
     return res;
}
int main()
{
    while(scanf("%d",&n)==1)
    printf("%d\n",n);
    return 0;
}

C++: #include <stdio.h>

int main() {
    int i, k, v,scan,an;
    int MAX_V = 1000000;
    int count[MAX_V];
    int sum[MAX_V];
    int prime[MAX_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;   
            } 
        }
    }
    count[0]=0;
    for(i=1;i<=MAX_V;i++){
        count[i]= count[i-1]+prime[i];
    }
    while(scanf("%d",&scan)!= EOF){
        an=count[scan]-count[0];
        printf("%d\n",an);
    }
    return 0; 
}

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

#define maxPN 100000
#define PNs  1000100
int countPN = 0, countPNs = 0;
int PrimeNum[maxPN], temp;
bool PN[PNs];

bool IsPrimeNumber(int x);

void PrimeN(){
	int i, j;
	PrimeNum[0] = 2;
	PN[2] = true;PrimeNum[countPN++] = 2;
	PN[3] = true;PrimeNum[countPN++] = 3;
//	PN[5] = true;PrimeNum[countPN++] = 5;
	
	for(i = 6; i  < PNs;i+=6){
		if(IsPrimeNumber(i-1)){
			PrimeNum[countPN++] = i-1;
			PN[i-1] = true;//cout<<i-1<<endl;
		}
		if(IsPrimeNumber(i+1)){
			PrimeNum[countPN++] = i+1;
			PN[i+1] = true;//cout<<i+1<<endl;
		}
		countPNs = i+1;//cout<<i-1<<" "<<PN[i-1]<<endl;
	}
}

bool IsPrimeNumber(int x){
	//if(x == 2 || x == 3) return true;
	//if(x <= 4 || x%2 == 0 || x%3 == 0)   return false;
	//if(x < countPNs) return PN[x];
	for(int i = 0; PrimeNum[i] * PrimeNum[i] <= x; i++)
		if(x%PrimeNum[i] == 0)return false;
	return true;
}


int main(){
//	clock_t start, end;
	int n = true, counta;
//	start = clock();
	PrimeN();
	cout<<PrimeNum[countPN-1]<<" "<<countPNs<<endl;
//	cout<<clock()-start<<"ms"<<endl;
	
	while(cin>>n){
		counta = 1;
		
		
		//cout<<(IsPrimeNumber(n)?"yes":"no")<<endl;
	//	start = clock();
		//cout<<IsPrimeNumber(n)<<endl;
		for(int i = 1; i <= n; i+=2){
			if(PN[i])counta++;
		//	cout<<i<<" "<<PN[i]<<endl;
		}
		if(n == 1) counta = 0;
		cout<<counta<<endl;
	//	cout<<clock()-start<<"ms"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main( void )
{
	int n;
	cin >> n;
	
	vector <bool> p(n+1, true);
	p[0] = p[1] = false;
	for ( int i = 4; i <= n; i += 2 )
	{
		p[i] = false;
	}
	for ( int i = 3; i <= n; i += 2 )
	{
		if ( p[i] )
		{
			for ( int j = i+i; j <= n; j += i )
			{
				p[j] = false;
			}
		}
	}

	int kotae = 1;
	for ( int i = 3; i <= n; i += 2 )
	{
		if ( p[i] )
			kotae++;
	}

	cout << kotae << endl;

	return 0;
}

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

int main(){
	int n;
	int prime[MAX],i,j;
	int count;
	bool flag;

	while((cin >> n)!= NULL){
		count = 0;
		for(i = 3; i <= n; i+=2){
			flag = true;
			for(j = 0; j < count; j++){
				if(i % prime[j] == 0){
					flag = false;
					break;
				}
			}
			if(flag == true){
				prime[count++] = i;
				cout<<count<<endl;
			}
		}
		if(n > 1)	count++; //2
		cout << count << endl;
		//delete[] prime;
	}
	return 0;
}

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

using namespace std;
const int MAX = 1000000;
int data[MAX];

void make(){
  fill(data,data+MAX,1);
  
  for(int i = 2; i*i < 1000000; i++){
    if(data[i] == 1){
      for(int j = i*2; j < 1000000; j+=i) data[j] = 0;
    }
  }
}

int main(){
  make();
  int in;
  while(cin >> in){
    
    int sum = 0;
    for(int i = 2; i <= in; i++){
      if(data[i] == 1) sum++;
    }
    
    cout << sum <<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
int main(){
    int a,t[1000000],u[1000000];
    for(int i=0;i<1000000;i++){
        t[i]=1;
    }
    t[0]=t[1]=u[0]=u[1]=0;
    for(int i=2;i<=1000000;i++){
        if(t[i]==1){
            for(int j=i+i;j<1000000;j+=i)t[j]=0;
            u[i]=u[i-1]+1;
        }else{
            u[i]=u[i-1];
        }
    }
    while(cin>>a){
        cout<<u[a]<<endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<cmath>
using namespace std;
bool book[1000000];
int search[1000000];
int main()
{
	int n,x=0;
	
	int m=floor(sqrt(999999)+0.5);
	for(int i=2;i<=m;i++)
	{
		if(book[i]==false)
		{
			search[i]=++x;
			for(int j=2*i;j<=999999;j+=i)
				book[j]=true;
		}
		else
			search[i]=x;
	}
	for(int i=m+1;i<=999999;i++)
	{
		if(book[i]==false)
			search[i]=++x;
		else
			search[i]=x;
	}
	
	while(~scanf("%d",&n))
	{
		printf("%d\n",search[n]);
	}
	return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int d=2,i,j,s[100000],x;

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