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 <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int eratos(int n){
	bool isprime[n + 1];
	for(int i = 0; i <= n; i++)isprime[i] = true;
	isprime[0] = isprime[1] = false;
	for(int i = 2; i * i <= n; i++){
		if(isprime[i]){
			int j = i + i;
			while(j <= n){
				isprime[j] = false;
				j = j + i;
			}
		}
	}
	int counter = 0;
	for(int i = 0; i <= n; i++){
		if(isprime[i] == true)counter++;
	}
	return counter;
}

int main(){
	int n;
	while(cin >> n){
		cout << eratos(n) << endl;
	}
}

C++: #include "stdio.h"
#include "iostream"
using namespace std;

int main()
{
    int n,count=0,m=0,i,j;
    while(cin>>n)
    {
        for(i=2;i<=n;i++)
        {
            for(j=1;j<i;j++)
            {
                if(i%j==0)count++;
            }
            
            if(count==1)
            m++;

            count=0;
        }
        cout<<m<<endl;
        m=0;
    }
    return 0;
}

C++: #include<stdio.h>
int main ()
{
int n,m,cou;m=0;cou=0;
while(scanf("%d",&n)!=EOF)
{
for(int i=3;i<=n;i+=2){
for(int k=3;k<i;k+=2){
if(i%k==0){m++;break;}}
if(m==0)cou++;
m=0;
}
if(n==2)cou=1;
else if(n==1)cou=0;
else cou++;
printf("%d\n",cou);
cou=0;
}
return 0;
}

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

C++: #include <iostream>
#include <vector>
using namespace std;
int main() {
  long n;
  vector<long> primes;
  primes.push_back(2);
  while (cin >> n) {
    for (int i = 3; i <= n; i += 2) {
      bool prime = true;
      for (long j : primes)
        if (i % j == 0) {
          prime = false;
          break;
        }
      if (prime) primes.push_back(i);
    }
    int x = 0;
    for (long j : primes)
      if (j <= n) x++;
    cout << x << endl;
  }
}

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

int main() {
	int n,yakusuu,sosuu;
	while (cin >> n) {
		sosuu = 0;
		for (int i = 1; i <= n; i++) {
			yakusuu = 0;
			for (int j = 1; j <= i; j++){
				if (i%j == 0)yakusuu++;
			}
			if (yakusuu == 2)sosuu++;
		}
		cout << sosuu << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
    vector<int> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;
      
      v[0]=false;
      v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]==true){
        for(int j = i;j<MAX;j*j)
        v[i]=false;
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())return 0;
      cout << v[a]<<endl;
    }
}

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[100000];
	int data[100000];
	int count;
	c[0]=c[1]=0;
	for(i=2;i<100000;i++){
		c[i]=1;
	}

	while((scanf("%d",&n)!=EOF)&&(n!=0)){
		
		count=0;
		for(i=0;i*i<=n;i++){
			data[i]=count;
			if(c[i]==1){
				count++;
				for(j=i+1;j<=n;j++){
					if(j%i==0){
						c[j]=0;
					}
				}
			}
		}

//		printf("%d",data[n]);
	}
	return 0;
}

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

int main() {

    vector<bool> primes (1000000);
    for (int n = 0; n < 1000000; n++) {
        primes[n] = true;
    }
    primes[0] = false;
    primes[1] = false;

    for (int n = 2; n < 1000000; n++) {
        if (primes[n]) {
            for (int k = 2*n; k < 1000000; k = k+n) {
                primes[k] = false;
            }
        }
    }

    int n;
    while (cin >> n) {
        int result = 0;
        for(int i = 0; i <= n; i++) {
            if ( primes[i] ) {
                result += 1;
            }
        }
        cout << result << endl;
    }
     
    return 0;
}

C++: #include<stdio.h>
#include<math.h>
main(){int i,j,n,p[1000000];scanf("%d",&n);for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)if(p[i])for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];printf("%d\n",j);}

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

#define PRIME_FLG_SIZE 1000000
#define PRIME_SUM_SIZE 1000000

bool primeFlg[PRIME_FLG_SIZE]; //[i]テ」ツ?古ァツエツ?ヲツ閉ーテ」ツ?凝」ツ?ゥテ」ツ??」ツ?凝」ツ?ョテァツョツ。テァツ青?
int primeSum[PRIME_SUM_SIZE]; //[0, i]テ」ツ?ョテゥツ鳴禿」ツ?ォテ・ツュツ佚・ツ慊ィテ」ツ?凖」ツつ凝ァツエツ?ヲツ閉ーテ」ツ?ョテヲツ閉ーテ」ツ?ョテァツョツ。テァツ青?

//テ」ツつィテ」ツδゥテ」ツδ暗」ツつケテ」ツδ?」ツδ催」ツつケテ」ツ?ョテ」ツ?オテ」ツつ凝」ツ??
void erato(){
  fill(primeFlg, primeFlg + PRIME_FLG_SIZE, true);
  primeFlg[0] = primeFlg[1] = false;

  for(int i = 2; i * i < PRIME_FLG_SIZE; i++){
    if(!primeFlg[i]) continue;
    for(int j = i * i; j < PRIME_FLG_SIZE; j += i){
      primeFlg[j] = false;
    }
  }

  fill(primeSum, primeSum + PRIME_SUM_SIZE, 0);

  for(int i = 1; i < PRIME_SUM_SIZE; i++){
    bool isPrime = primeFlg[i];
    primeSum[i] = primeSum[i - 1] + (isPrime ? 1 : 0);
  }
}

int main(){
  erato();

  int n;

  while(cin >> n){
    cout << primeSum[n] << endl;
  }
}

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

class PrimeNumbers
{
public:
	vector<int> primeNumbers;

	PrimeNumbers()
	{
		this->createPrimeNumbers();
	}
	
	int answer(int N)
	{
		int result = 0;
		for(auto it = this->primeNumbers.begin(); it != this->primeNumbers.end(); it++)
		{
			if(*it <= N)result++;
			else break;
		}
		return result;
	}

	bool checkOf(int n)
	{
		if(n % 2 == 0)return false;

		bool prime = false;
		for(auto it = this->primeNumbers.begin(); it != this->primeNumbers.end(); it++)
		{
			if(n == *it)
			{
				prime = true;
				break;
			}
		}
		return prime;
	}

	void createPrimeNumbers()
	{
		int max_number = 100000;
		this->primeNumbers = vector<int>();
		this->primeNumbers.push_back( 2 );
		for(int i = 3; i < max_number; i += 2)
		{
			bool prime = true;
			for(auto it = this->primeNumbers.begin(); it != this->primeNumbers.end(); it++)
			{
				if(i % *it == 0)
				{
					prime = false;
					break;
				}
			}
			if(prime)
			{
				this->primeNumbers.push_back(i);
			}
		}
	}

};

int main()
{
	int N;
	PrimeNumbers pn = PrimeNumbers();
	while(cin >> N)
	{
		cout << pn.answer(N) << endl;
	}
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
using namespace std;
bool dp[1000001] = {};
int sosuu() {
	dp[1] = true;
	for (int i = 2;i <= 1000;++i) {
		if (dp[i] == false) {
			for (int q = 2;q <= 1000000 / i + 1;++q) {
				dp[i*q] = true;
			}
		}
	}
	return 0;
}
int main() {
	sosuu();
	int n = 0;
	while (cin >> n) {
		int count = 0;
		for (int i = 1;i <= n;++i) {
			if (dp[i] == false) count++;
		}
		printf("%d\n", count);
	}
}

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

int main()
{
	long int n,m;
	while(cin>>n){
		long int i;
		int number[n]={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;
	}
}