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<iostream>

using namespace std;

int n;
int prime[1000000];
int checked[1000000];
int primesum[1000000];
int result[30];
int datasets;

int main()
{
	prime[0] = 0;
	prime[1] = 0;
	prime[2] = 1;
	primesum[0] = 0;
	primesum[1] = 0;
	primesum[2] = 1;

	for (int a = 3; a<1000000; a++)
	{
		prime[a] = 1;
	}

	for (int a = 3; a<1001; a++)
	{
		if (checked[a] == 0)
		{
			checked[a] = 1;
			for (int b = 2; b<a; b++)
			{
				if (a%b == 0)
				{
					prime[a] = 0;
					break;
				}
			}
			if (prime[a] == 1)
			{
				for (int c = 2 * a; c<1000000; c += a)
				{
					checked[c] = 1;
					prime[c] = 0;
				}
			}
		}
	}

	for (int a = 3; a<1000000; a++)
	{
		primesum[a] = primesum[a - 1] + prime[a];
	}

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

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int N,count=0;
	cin >> N;
	for(int x=2;x<=N;x++){
		int flag = 0;
		for(int y=2;y<x;y++){
			if((x%y)==0)	flag = 1;
		}
		if(flag == 0)	count++;
	}
	cout << count << endl;
	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;
}

C++: #include<iostream>
int main(){
	int n,m,l;
	while(1){
		std::cin>>n;
		if(std::cin.eof())break;
		m=0,l=0;
		for(int i=2;i<=n;i++){
			for(int j=2;j<=i/2;j++){
				if(i%j==0)m++;
			}
			if(m==0)l++;
			m=0;
		}
		std::cout<<l<<std::endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int solve(int n){
    int ans=0,sum;
    for(int i=1;i<n+1;i++){
        sum=0;
        for(int j=1;j<i+1;j++){
            if(i%j==0)sum++;
        }
        if(sum==2)ans++;
    }
    return ans;
}
int main(void){
    int n;
    while(cin>>n){
        cout<<solve(n)<<endl;
    }
    return 0;
}

C++: 
#include<stdio.h>
int main()
{
    int a,N,M,sum=0,i,j,count=0,flag=0;
    while (scanf ("%d",&M)!=EOF )
        {
            for(i=2;i<=M;i++)
            {
                flag=0;

                if(i>2)
                {
                    for(j=2;j<i;j++)
                    {
                        if(i%j==0)
                        {
                            flag=1;
                            break;
                        }
                    }
                    if(flag==0)
                    {
                        count++;

                    }
                }

            }
                  printf("%d\n",count);
                  count=0;
        }

    return 0;
}

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

int main()
{
	bool is_prime[100000]:
	
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<1000000;i<i++){
		is_prime[i]=true;
	}
	
	for(int i=2;i*i<1000000;i++){
		if(is_prime[i]){
			for(int j=i*i;j<1000000;j+=i){
				is_primej]=false;
			}
		}
	}
	
	int n_prime[1000000];
	
	int cnt=0;
	for(int i=0;i<1000000;i++){
		if(is_prime[i]){
			cnt++;
		}
		
		n_prime[i]=cnt;
	}
	
	while(true){
		int n;
		cin>>n;
		if(cin.eof())
			break;
		
		cout<<n_prime[n]<<endl;
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX_VALUE = 100007;
bool prime[MAX_VALUE];

int main() {
  vi primes;
  FOR(i, 2, MAX_VALUE){
    if(prime[i]) continue;
    primes.push_back(i);
    for(int j = i * 2; j<MAX_VALUE; j+=i)
      prime[j]=true;
  }

  int n;
  while(cin >> n) {
    REP(i, primes.size()){
      if(primes[i]-1 >= n) {
        cout << i << endl;
        break;
      }
    }
  }
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999

using namespace std;

typedef long long ll;

vector<int>primenumber;
int d[10500000];

int main()
{
	int n;
	
	primenumber.push_back(2);
	d[2] = 1;

	int maxn = 0;

	while (cin >> n) {
		if (maxn<n) {
			for (int i = max(maxn+1,3); i <= n; i++) {
				int ope = 1;
				for (int j = 0; j < primenumber.size(); j++) {
					if (primenumber[j] * primenumber[j] > i)break;
					if (i%primenumber[j] == 0) {
						ope = 0;
						break;
					}
				}
				if (ope == 1)primenumber.push_back(i);
				d[i] = primenumber.size();
			}
			maxn = n;
		}
		cout << d[n] << endl;
	}
	
	for (int i = 0; i < primenumber.size(); i++) {
		cout << primenumber[i] << endl;
	}

	return 0;
}

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

int main(){
  
  int n;

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

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;

bool isPrime(int num);

int main()
{
	int count = 0;
	/*int m = 2, n = 0, num;

	cin >> num;

	int *data = new int[num + 1];
	int *result = new int[num + 1];

	data[0] = 0;
	data[1] = 0;

	do
	{
		for (i = 2 * m; i < num + 1; i += m)
		{

		}
	}
	while
	{

	}*/
	const int N = 9999999;
	int n;
	std::vector<bool> isPrime(N + 1, true);    // ?´???°????????°?????¨??¨ON???

	while (cin >> n)
	{
		count = 0;
		for (int i = 2; i <= n; ++i) {
			if (isPrime[i])
			{
				count++;

				for (int k = i + i; k <= n; k += i)
					isPrime[k] = false;      // ?´???°????????°????´???°????????°?????¨???OFF???
			}
		}

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






	
}

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

int main(){
	bool b[1000000] = {};
	for(int i = 2; i < 1000000; i++){
		b[i] = true;
	}
	for(int i = 2; i < 1000; i++){
		if(b[i]){
			for(int j = i * i; j < 1000000; j += i){
				b[j] = false;
			}
		}
	}

	int n, count = 0;
	cin >> n;
	for(int i = 0; i <= n; i++){
		if(b[i]){
			count ++;
		}
	}
	cout << count << endl;
	return 0;
}