Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [100]int
	var inputCount, primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		resultArr[inputCount] = primeCount
		if inputCount == 30 {
			break
		}
		primeCount = 0
		inputCount++
	}
	for _, v := range resultArr {
		fmt.Printf("%d\n", v)
	}
}

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
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int p[1000000];
int cnt[1000000];

int main()
{
  fill(p, p + 1000000, 1);
  p[0] = p[1] = 0;
  for(int i=2;i<1000000;i++)
    for(int j=i*2;j<1000000;j+=i)
      p[j] = 0;

  for(int i=1;i<1000000;i++)
    cnt[i] = cnt[i-1] + p[i];

  int n;
  while(scanf("%d", &n) != -1)
    printf("%d\n", cnt[n]);

  return 0;
}

C++: import math
import sys

def prime_calc(n):
    rootN = math.floor(math.sqrt(n))
    prime = [2]
    data = [i + 1 for i in range(2,n,2)]
    while True:
        p = data[0]
        if rootN <= p:
            return len(prime + data)

        prime.append(p)
        data = [e for e in data if e % p != 0]

def main():
    l = []

    for line in sys.stdin:
        l.append(line)        

    for line in l:
        print(prime_calc(line))

if __name__ == "__main__":
    main()

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

//素数かどうか判定する関数
bool judge( int x )
{
    int count = 0;

    for( int i = 1; i <= x; i++ )
    {
        if( x % i == 0)
            count++;
    }

    if( count == 2 )
        return true;
    else
        return false;
}

int main()
{
    int n;

    while( cin >> n )
    {
        int count = 0;

        for( int i = 1; i <= n; i++ )
        {
            if( judge(i) )
                count++;
        }

        cout << count << endl;
    }

    return 0;
}

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

int main() {
	// your code goes here
	int nu[30];
	int num;
	int count = 0;
	int max = 29;
	for(int x=0;x<30;x++){
		nu [x] = -1;
		cin >> nu[x];
		if (nu[x] == -1) {
			max = x;
			break;
		}
	}
	for (int y=0;y<max;y++) {
		num = nu[y];
		count = 0;
		
		for (int i = 1;i<=num;i++) {
		if(i%2==0) {
			//cout <<"2: "<<i<<endl;
			count ++;
			continue;
		}
		for (int j=3;j<(int)sqrt(i)+1;j=j+2) {
			if (i%j==0) {
				count ++;
				//cout <<"i: "<<i<<" j: "<<j<<endl;
				break;
			}
		}
	}
	cout << (num-count) <<endl;
	//cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cmath>

int prime(int number) {
    int s_num = sqrt(number);
    if (number == 2) {
        return 1; 
    } else if (number % 2 == 0) {
        return 0;
    }
    for (int i = 3; i <= s_num; i += 2) {
        if (number % i == 0) {
            return 0;
        }
    }
    return 1;
}

int main(void) {
    int number;
    int count = 0;
    int max = 1;

    std::vector<int> v(1000000, 0);

    while (std::cin >> number) {
        if (number > max) {
            for (int i = max + 1; i <= number; i++) {
                if (prime(i) == 1) {
                    count++;
                }
                v[i - 1] = count;
                max = number;
            }
        }
        std::cout << v[number - 1] << std::endl;
    }
    return 0;
}

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

#define MAX 1000000 

bool prime_table[MAX];
int head;

int main(){
	int n, i, j;
	int result;
	// make table
	for (i = 0; i < MAX; i++) {
		if(i==0||i==1){
			prime_table[i] = false;
		}else{
			prime_table[i] = true;
		}
	}
	// find prime
	for (i = 2; i < MAX; i++) {
		if(prime_table[i]){
			for (j = i+i; j < MAX; j+=i) {
				prime_table[j] = false;
			}
		}
	}
	
	while(cin >> n){
		result = 0;
		for (i = 0; i < n; i++) {
			if(prime_table[i])
				result++;
		}
		cout << result << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<windows.h>
#include<conio.h>
#include<String>
#include<time.h>
#include<math.h>

using namespace std;

int main() {

	int c = 0;
	int i = 1;
	unsigned long long a = 0;
	unsigned long long b = 0;
	unsigned long long sosuu[100000] = { 0 };
	char fire = 0;
	int pattara = 0;
	cin >> c;
	cout << 2;
	/*while(i>-1)*/for(int i=0;i<c;i++){
		/*for (int z = 0; z < a;z++){*/
		for (int q = 1; q <= sqrt(i); q++) {
			sosuu[pattara] = i;
			if (sosuu[pattara] % 2 == 0) {
				break;
			}
			if (sosuu[pattara] % q == 0) {
				b += 1;
			}

		}

		/*if (b == 1) {
			fire = _getch();
			pattara++;
			cout << sosuu[pattara - 1] << " " << pattara << endl;

		}*/
		b = 0;
		/*i++;*/
		if (pattara == c){
			break;
		}
	}
	cout << pattara << endl;


	/*system("pause");
	return 0;*/
}

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

int main(){
  bool a[1000000];

  a[0]=a[1]=false;
  for(int i=2;i<1000000;i++){
    a[i]=true;
  }

  for(int i=2;i*i<1000000;i++){
    if(a[i]){
      for(int j=i*i;j<10000000;j+=i){
        a[j]=false;
      }
    }
  }

  int n[1000000];

  int tmp=0;
  for(int i=0;i<1000000;i++){
    if(a[i]){
      tmp++;
    }
    n[i]=tmp;
  }

  while(true){
    int m;
    cin>>m;

    if(cin.eof()){
      break;
    }
    
    cout<<n[m]<<endl;

  }

  return 0;
}

C++: #include <stdio.h>
#include <algorithm>

using namespace std;

void set_prime_number(bool* array, int num) {

  fill(array, array + num, true);
  array[0] = array[1] = false;
  for (int i = 2; i < num; i++) {
    if (!array[i]) continue;
    for (int j = i * 2; j < num; j += i) {
      array[j] = false;
    }
  }

}

int main() {
  bool prime_number[999999];
  int num;
  int nump=0;
  int j=0;
  int cnt=0;

	while(scanf("%d",&num)!=EOF){
	  set_prime_number(prime_number, num);
	 for (int i = 0; i < num; i++) {
	 if (prime_number[i])cnt++;
	 }
	 printf("%d ",cnt);
	 cnt=0;
	}


  return 0;
}

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


using namespace std;

int main() {
	vector<int> prime_num{ 2, 3 };
	int n;

	while (cin >> n){
		int result;
		if (n <= 1) {
			result = 0;
		}
		else if (n == 2){
			result = 1;
		}
		else if (n < prime_num.back()){
			result = count_if(prime_num.begin(), prime_num.end(), [n](int a){return a <= n; });
		}
		else {
			for (int i = prime_num.back() + 2; i <= n; i += 2) {
				if (all_of(prime_num.begin(), prime_num.end(), [i](int a){return (i % a) != 0; })) {
					prime_num.push_back(i);
				}
			}
			result = prime_num.size();
		}

		cout << result << endl;
	}

	return 0;
}