Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	num := make([]bool, 1000000)

	for sc.Scan() {
		var nmpr int

		n, _ := strconv.Atoi(sc.Text())

		lmt := int(math.Sqrt(float64(n)))

		for i := 2; i <= lmt; i++ {
			for j := 2; i*j <= n; j++ {
				if !num[i*j] {
					num[i*j] = true
				}
			}
		}

		for t := 2; t <= n; t++ {
			if !num[t] {
				nmpr++
			}
		}

		fmt.Println(nmpr)
	}

}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int prime[100000] = {0};

void makeprime(long long int n)
{
    int k = 1;
    prime[0] = 2;
    for (long long int i = 3; i < n; i++)
    {
        double temp = sqrt(i);
        for (int j = 0; i % prime[j] != 0; j++)
        {
            if (temp < prime[j])
            {
                prime[k++] = i;
                break;
            }
        }
    }
    // rep(i,1000){
    //     cout<<prime[i]<<" ";
    // }
}

int main()
{
    makeprime(999999);
    int n;
    int i;
    while (cin >> n)
    {
        i = 0;
        while (true)
        {
            if (n < prime[i])
            {
                break;
            }
            i++;
        }
        cout << i << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int m,i,k,n;
	while(cin>>n)
	{
		int j=0;
		for(m=2;m<=n;m++)
		{
		    k=int(sqrt(double(m)));
		    i=2;
		    while(m%i&&i<=k)
				i++;
			if(i>k)
				j+=1;
		}
		cout<<j<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<math.h>
int a[20000];
int main()
{
    int i, j, q, n, co;
    while(scanf("%d",&n)==1)
    {
        co=0;
        a[0]=1;
        a[1]=1;
        for(i=4 ; i<=n ; i+=2)
        {
            a[i]=1;
        }
        q=sqrt(n);
        for(i=3 ; i<=q ; i+=2)
        {
            if(a[i]==0)
            {
                for(j=i*i ; j<n ; j+=i)
                {
                    a[j]=1;
                }
            }
        }
        for(i=0 ; i<=n ; i++)
        {
            if(a[i]==0)
            {
                co++;
            }
        }
        printf("%d\n",co);
    }
    return 0 ;
}

C++: #include <stdio.h>
#include <string.h>
#include <stack>
#include <deque>
#include <stdlib.h>
#include <math.h>
#include <queue>
#include <limits.h>
#include <time.h>
#include <utility>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <list>
#include <iostream>
using namespace std;
#define rookloop() for(int li=0;li<4;li++)
#define knightloop() for(int li=0;li<8;li++)
#define kingloop() for(int li=0;li<8;li++)
//int dx[]={1,-1,0,0},dy[]={0,0,1,-1}; // for left right up down move
//int dx[]={1,1,1,-1,-1,-1,0,0},dy[]={0,1,-1,0,1,-1,1,-1}; // for king move
//int dx[]={1,1,-1,-1,-2,-2,2,2},dy[]={2,-2,-2,2,1,-1,1,-1}; // for knight move
#define scI(a) scanf("%d",&a)
#define scL(a) scanf("%lld",&a)
#define scD(a) scanf("%lf",&a)
typedef long long L;
typedef unsigned long long uL;
//this function is for Prime Numbers.R__PrimeList vector contains prime numbes upto R__MaximumForPrime.R__PrimeDetectArr is used
//for a number is prime or not.if a number is prime than R__PrimeDetectArr array contains in that position 'P'.
int R__MaximumForPrime=999999;char R__PrimeDetectArr[100000000+1];vector <int> R__PrimeList;
void R__Sieve(){R__PrimeDetectArr[2]='P';R__PrimeList.push_back(2);for(L r_ip01=3;r_ip01<=R__MaximumForPrime;r_ip01=r_ip01+2){if(R__PrimeDetectArr[r_ip01]==0){R__PrimeDetectArr[r_ip01]='P';R__PrimeList.push_back(r_ip01);for(L r_jp01=r_ip01*r_ip01;r_jp01<=R__MaximumForPrime;r_jp01=r_jp01+r_ip01) R__PrimeDetectArr[r_jp01]='1';}}}
//Euler Toitent Phi Function; suppose A=12;how many number 1 to A that gcd(A,number)=1;the answer give us R__Phi
//for the function must call R__Sieve();then call R__Euler_Toitent_Phi1();
/*vector <int> R__Phi;
void R__Euler_Toitent_Phi1(){for(int r_ip01=0;r_ip01<=R__MaximumForPrime;r_ip01++) R__Phi.push_back(r_ip01);R__Phi[1]=1;for(int r_ip01=0;r_ip01<R__PrimeList.size();r_ip01++){for(int r_jp01=R__PrimeList[r_ip01];r_jp01<=R__MaximumForPrime;r_jp01=r_jp01+R__PrimeList[r_ip01])R__Phi[r_jp01]=R__Phi[r_jp01]-R__Phi[r_jp01]/R__PrimeList[r_ip01];}}*/
//Extend Euclid - ax+by=gcd(a,b)=d;parameter pass a,b,d,x,y;so you get result in x,y,d variable;
void R__Extend_Euclid(L a,L b,L &d,L &x,L &y){if(!b) {x=1,y=0,d=a;}else R__Extend_Euclid(b,a%b,d,y,x),y-=(a/b)*x;}
template <class R> string R__MonthName(R name){string mon[15];mon[1]="January";mon[2]="February";mon[3]="March";mon[4]="April";mon[5]="May";mon[6]="June";mon[7]="July";mon[8]="August";mon[9]="September";mon[10]="October";mon[11]="November";mon[12]="December";return mon[name];}
template <class R> R R__MonthDay(R num){R month[13];month[1]=31;month[2]=28;month[3]=31;month[4]=30;month[5]=31;month[6]=30;month[7]=31;month[8]=31;month[9]=30;month[10]=31;month[11]=30;month[12]=31;return month[num];}
template <class R> R R__GCD(R a,R b){if(a==0&&b==0) return 0;if(a==0) return 1;if(b==0) return a;else return R__GCD(b,a%b);}
template <class R> R R__LCM(R a,R b){return (a*b)/R__GCD(a,b);}
template <class R> R R__POW( R a, R b){if(b==0) return 1; R x=a;for(R i=2;i<=b;i++) a=a*x;return a;}
template <class R> R R__Josephus(R n,R k){R ans=1;for(R i=2;i<=n;i++)ans=(ans+k-1)%i+1;return ans;}
template <class R> R R__BigMod(R a,R b,R c){if(a==0) return 0;if(b==0) return 1;if(b%2==0){R x=R__BigMod(a,b/2,c)%c;return (x*x)%c;}else return  ((a%c)*R__BigMod(a,b-1,c)%c)%c;}
template <class R> R R__Factorial(R a){R b=1;for(R i=1;i<=a;i++)b=b*i;return b;}
template <class R> R R__BinarySearch(R a[],R l,R h,R n){while(l<=h){R m=(l+h)/2;if(n<a[m])h=m-1;else if(n>a[m])l=m+1;else return m;} return -1;}
//In R__InverseMod two arguments a and b must be coprime
template <class R> R R__InverseMod(R a,R b){if(b==1) return 1;R b0=b,x0=0,x1=1;while(a>1){R temp = x0;x0=x1-(a/b)*x0;x1=temp;temp=b;b=a%b;a=temp;}if(x1<0) x1=x1+b0;return x1;}
template <class R> R R__Euler_Toitent_Phi2(R a){R result = a;for(R i=2;i*i<=a;i++){if(a%i==0) result=result-result/i;while(a%i==0) a=a/i;}if(a>1) result=result-result/a;return result;}
int main()
{
    //time_t t1=clock();
    //freopen("input.txt","r",stdin);//freopen("output.txt","w",stdout);
    R__Sieve();
    vector <int> answer;
    int f=0;
    for(int i=0;i<=R__MaximumForPrime;i++)
    {
        if(R__PrimeDetectArr[i]=='P') f++;
        answer.push_back(f);
    }
    int number;
    while(cin>>number)
    {
        cout<<answer[number]<<"\n";
    }
    //time_t t2=clock();
    //cout<<(t2-t1);
    return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int whether(int num);
int count(int num);
int main(){
    int n;
    while(cin >> n){
        cout << count(n)+1<<endl;
    }
    return 0;
}

int whether(int num){//if num is prime, 1
    int s=sqrt(num);
    for(int i=3; i<=s; i+=2){
        if(num%i==0){ return 0; }
    }
    return 1;
}
int count(int num)
    if(num==99) return 24;
    if(num==999) return 167;
    if(num==9999) return 1228;
    if(num==99999) return 9591;
    if(num<2) return 0;
    if(num==2) return 1;
    if(num%2==0) return count(num-1);
    int a;
    a=whether(num) +count(num-2);
    return a;
}