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:
		return true
	case num < 2 || num%2 == 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++: ///bismillah_hir_rahmanir_rahim

#include<bits/stdc++.h>
using namespace std;
#define n 999999


int i,j,p,f;

int arr [n];

void seive ()
{

    //arr[0]=arr[1]=1;
    arr[2]=0;

    for (i=4; i<=n; i=i+2)
    {
        arr[i]=1;
    }

    for(i=3; i<=sqrt(n); i=i+2)
    {
        if(arr[i]==0)
        {
            for( j=i*i; j<=n; j=j+(2*i) )
            {
                arr[j]=1;

            }
        }
    }

//printf("%d\n",arr[5]);

//    for( p=2; p<=100; p++)
//    {
//        if(arr[p]==0)
//        {
//            printf("%d ",p);
//        }
//    }


}

int main()
{

    seive();

    int num,count,p;

    while ( scanf("%d",&num)==1)
    {
        count = 0;

        for( p=2; p<=num; p++)
        {
            if(arr[p]==0)
            {
                count++;
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

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

typedef unsigned long long ull;

ull qtde[1000000] = { 0, 0, 1, 2 };

bool isPrime(ull x) {
  ull i = 6;
  ull root = (ull)sqrt(x) + 2;
	if (x <= 1)
		return false;
  if (x == 2 || x == 3)
    return true;
  if (x % 2 == 0 || x % 3 == 0)
    return false;

  while (i <= root) {
    if (x % (i - 1) == 0)
      return false;
    if (x % (i + 1) == 0)
      return false;
    i += 6;
  }

  return true;
}

int main(int argc, char const *argv[]) {
    ull n;
    ull i;
    
    for (int i = 3; i < 1000000; i++)
      qtde[i] = qtde[i-1] + isPrime(i);

    while (cin >> n)
      cout << qtde[n] << endl;

    return 0;
}

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

const int MAX = 1000000;

vector<bool> sieve(int n = MAX) {
	vector<bool> prime(n, true);
	prime[0] = prime[1] = false;
	for(int i = 2; i < n; ++i)
	if(prime[i])
		for(int j = i * 2; j < n; j += i)
			prime[j] = false;

	return prime;
}

int main() {
	vector<bool> prime = sieve();
	vector<int> num(MAX, 0);

	for(int i = 0; i < MAX - 1; ++i)
		num[i + 1] = num[i] + prime[i + 1];

	for(int n; scanf("%d", &n) == 1;)
		printf("%d\n", num[n]);

	return EXIT_SUCCESS;
}

C++: #include <iostream>

using namespace std;
int main(){
	bool n[1000000];
	for(int i=0; i<1000000; i++){ n[i]=1; }
	n[0]=0;
	n[1]=0;

	for(int i=2; i<1000000; i++){
		if(n[i]==0){ break; }
		if(n[i]==1){
			for(int j=i*2; j<1000000; j+=i){ n[j]=0;	}
		}
	}

	int num;
	int count;
	while(cin >> num){
		count = 0;
		for(int i=2; i<=num; i++){
			count += n[i];
		}
		cout << count << endl;
	}

	return 0;
}

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

bool isprime(int &num)
{
    static int i;
    i = 2;
    for(;i< num; i++)
        if(num%i==0) return false;
    return true;
}

int countprime(int &num)
{
    static int i;
    static int count;
    count = 0;
    i = 2;
    for(;i<=num;i++)
        if(isprime(i)) count++;
    return count;
}

int main()
{
    int num[30];
    for(int i = 0; i < 30; i++)
        cin >> num[i];

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

C++: #include <iostream>
using namespace std;
const int len = 999999;

int main()
{
    int arr[100] = {0},n,count=0;
     cin>>n;
    for (int i = 2; i < n; i++)
    {
        for (int j = i * i; j < n; j+=i)
        {
            arr[j - 1] = 1;
        }
    }
    for (int i = 1; i < n; i++)
    {

        if ((arr[i - 1] == 0)&&(i>1))
            count++;


    }
    std::cout <<count <<endl;
}

C++: #include<bits/stdc++.h>
#include<iostream>
#define LIM 999999
using namespace std;
long long int i,j,a,odd;
bool prime[LIM];
long long int arr[999999];
void sieve()
{
    
    arr[a++]=2;
    for(i=3;i<=LIM;i+=2)
    {
        if(!prime[i])
        {
            arr[a++]=i;
            if(i*i<=LIM)
            {
                odd=i;
                
                for(j=i*i;j<=LIM;j=i*odd)
                {
                    prime[j]=true;
                    odd+=2;
                }
            }
        }
        if(a==999999)
            break;
    }
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    sieve();
    long long int k, num, count = 0;
    k=0;
    while(scanf("%lld", &num)!=EOF)
    {
        k=0;
        count = 0;

        for(int i=1; i<=num; i++)
        {
            if(i == arr[k])
                {
                    count++;
                    k++;
                }
        }
        printf("%lld\n", count);
    }
    return 0;
}

C++: // 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

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

	vector<int> primes;
	primes.push_back(2);
	for(int i = 3; i <= 999999; i += 2){
		bool ok = true;
		for(int j = 2; j * j <= i; j++){
			if(i % j == 0)ok = false;
		}
		if(ok)primes.push_back(i);
	}
	int n;
	while(cin >> n){
		int ans = 0;
		for(auto i:primes)if(i <= n)ans++;
		cout << ans << '\n';
	}
	return 0;
}
// Write Here

C++: #include<cstdio>
#include<vector>
#include<cmath>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n)!=-1){
        int ans=0;
        vector<bool> tab(n+1,true);
        int upto=sqrt(n);
        for(int i=2;i<=upto;i++){
            if(tab[i]){
                for(int j=i*2;j<=n;j+=i){
                    tab[j]=false;
                }
            }
        }
        for(int i=2;i<=n;i++){
            if(tab[i]) ans++;
        }
        printf("%d\n",ans);
    }
}

C++: #include <iostream>
using namespace std;
bool prime[999999]={1,1,0,0};
int main(){
  for(int i=2;i<999999;i++){
    if(prime[i]==0) for(int j=i<<1;j<99999;j+=i)
    prime[j]=1;
  }
  int n;
  while(cin>>n){
    int ans=0;
    for(int i=2;i<=n;i++)
      ans+=!prime[i];
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
#define N 1000000

int main()
{
	bool prm[N];
	for(int i=0; i<N; i++)
	{
		prm[i]=true;
         }
		int upto= (int) sqrt(N);
		for(int i=2;i<= upto; i++)
		{
			if(prm[i])
{
				for(int j=2; j*i<N; j++)
				{
				    prm[i*j]=false;
				}
}
		}
		int n;
		while(cin>>n)
		{
			int count=0;
			for(int i=2; i<=n; i++)
			{
				if(prm[i])
					count++;
			}
			cout<<count<<endl;
		}
	}
	return 0;
}