Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [40]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 "stdio.h"
#include"time.h"
const int MAX_V = 1000000; // 100????????§????´???°??¨?????????
int prime[MAX_V+1]; // 1????´???°,0????´???°??§?????????
int main() {
    int i, k, n;
    clock_t start, now;//??£?¨?
    for(i = 2; i <= MAX_V; i++){
        prime[i] = 1; // 2??\???????´???°??¨??????
    }
    for(i = 2; i * i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°???2?????\???????????°????´???°??§?????????
            }
        }
    }
    while (1) {
        int cnt = 0;
        scanf("%d",&n);
        start = clock(); // ????§???????
        if (n == EOF)break;
        for(i = n;1 <= i;i--){
            if(prime[i] == 1){  //??????????´???°
                cnt++;
            }
        }
        now = clock(); // ????????????
        printf("%d\n",cnt);//for?????????????????????
        printf("%f\n", (double)(now - start) / CLOCKS_PER_SEC);
    }
    return 0;
}
//????¨??????¨????????????????????????

C++: #include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
const int MAX_N = int(1e6);
??
int main(){
??
????int n, i, j, maxin = 2;
????bool jud;
????vector <int> vec;
????for(i = 2;i <= MAX_N; i++){
????????????????jud = 0;
????????????????for(j = 0;?? j < vec.size() ; j++){
????????????????????if(vec[ j ] * vec[ j ] > i) break;
????????????????????if( !( i % vec[ j ] ) ){
????????????????????????jud = 1;
????????????????????????break;
????????????????????}
????????????????}
????????????????if(!jud)
????????????????????vec.push_back( i );
????????????}
????while(cin >> n){
????????cout << upper_bound(vec.begin(), vec.end(), n) - vec.begin()???? <<endl;
????}
}

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

bool prime[10000005];
int p[700000]; 
int main()
{	
	int k=0;
	prime[0]=1;
	prime[1]=1;
	for(int i=2;i<=999999;++i)
	{
		if(prime[i]==0)
		{	
			p[k++]=i;		
			for(int j=i+i;j<=999999;j+=i)	
			{
				prime[j]=1;
			}
		}
	}
	int n;
	while(cin>>n){
		//for(int i=0;i<10;++i)cout<<p[i]<<endl;
		int ans = lower_bound(p,p+k,n)-p;
		//cout<<p[ans]<<endl;
		if(p[ans]==n)ans++;
		cout<<ans<<endl;
	} 

}

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

int Era(int N) {
	int prime_num = 0;
	int* array = new int[N + 1];
	for (int i = 2; i < N + 1; i++) {
		array[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (array[i]) {
			for (int j = 0; i*(j + 2) <= N; j++) {
				array[i*(j + 2)] = 0;
			}
		}
	}
	for (int i = 2; i < N + 1; i++) {
		if (array[i])prime_num++;
	}
	return prime_num;
}

int main() {
	int num;
	while (cin >> num) {
		cout << Era(num) << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int i,j,number,count=0,hantei=0;
	while(cin>>number){
		count=0;
		for(i=2;i<number;i++){
			hantei=0;
			for(j=0;j<i/2;j++){
				if(i%j==0){
					hantei++;
				}
			}
			if(hantei==0){
				count++;
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  const int max = 1000000;
  vector<int> result;
  bool nums[max];
  for (int i = 2; i < max; i++)
    nums[i] = true;
  for (int i = 2; i < max; i++) {
    if (!nums[i])
      continue;
    else if (i * i > max)
      break;
    for (int j = i+1; j < max; j++) {
      if (!nums[j])
        continue;
      else if (j % i == 0)
        nums[j] = false;
    }
  }

  while (cin >> n) {
    int piyo = 0;
    for (int i = 2; i <= n; i++)
      if (nums[i])
        piyo++;
    result.push_back(piyo);
  }

  for (int i = 0; i < result.size(); i++)
    cout << result[i] << endl;
  return 0;
}

C++: #include<iostream>
int main(){
	int n;
	while(1){
		std::cin>>n;
		if(std::cin.eof())break;
		int 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<bits//stdc++.h>
using namespace std;
int main(){
	int a[1000000];
	a[0]=1;
	a[1]=1;
	for(int i=2;i<1000000;){
		if(a[i]==0){
			for(int j=i;j<1000000;j+=i){
				a[j]=1;
			}
		}
	}
	int b;
	while(cin>>b){
		int c=0;
		for(int i=0;i<b;i++){
			if(a[i]>b)break;
			else {
				if(a[i]==1) c++;
			}
		}
		cout<<c<<endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <sstream>
 
using namespace std;
 
int main(){
    int n;
    int nums[100000] = {0};
    while(cin >> n){
        int count = 0;
        int qf = 0;
        int qe = 0;
        for(int i = 2; i <= n; i++){
            bool f = false;
            for(int qe = 0; qe < qf; qe++ ){
                if(i < nums[qe] * nums[qe]) break;
                if(i % nums[qe] == 0) {
                    f = true;
                    break;
                }
            }
            if(!f) { count++; nums[qf] = i; qf++; }
        }
        cout << count << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
#define MAX 1000000
int main( void )
{
	vector <bool> primes(MAX+1, false);

	for ( int i = 3; i <= MAX; i += 2 )
	{
		primes[i] = true;
	}

	for ( int i = 3; i <= MAX; i += 2 )
	{
		if ( primes[i] )
		{
			for ( int j = i + i; j <= MAX; j += i )
			{
				primes[j] = false;
			}
		}
	}

	vector <int> answers;
	while ( !cin.eof() )
	{
		int n;
		cin >> n;
		if ( cin.eof() )
			break;

		int c = 0;
		if ( n == 2 )
			c = 1;
		else if( n < 2 )
			c = 0;
		else
		{
			c = 1;
			for ( int i = 3; i <= n; i += 2 )
			{
				if ( primes[i] )
					c++;
			}
		}

		answers.push_back( c );
	}

	for ( vector <int>::iterator it = answers.begin(); it != answers.end(); it++ )
	{
		cout << *it << endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600

#define MAX_PRIME 1000000

vector<int> primes;

// sieve of Erastosthenes
inline void prime_list(){
  vector<bool> isPrime(MAX_PRIME+1, true);
  const int sz = MAX_PRIME;
  isPrime[0]=isPrime[1]=false;
  for(int i=4;i<=sz;i+=2) isPrime[i]=false;
  primes.pb(2);
  for(int i=3; i<=sz; i+=2){
    if(isPrime[i]){
      primes.pb(i);
      for(long j=(long)i*i; j<=sz; j+=i) isPrime[j]=false;
    }
  }
}

int main(){
  prime_list();
  int d;
  while(cin>>d){
    cout << upper_bound(all(primes), d) - primes.begin() << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main() {
  long n;
  while (cin >> n) {
    if (n == 1) {
      cout << 0 << endl;
      continue;
    }
    int x = 1;
    if (n == 2) {
      cout << x << endl;
      continue;
    }
    x++;
    for (int i = 3; i <= n; i += 2)
      for (int j = 2; j * j <= i; j++) {
        if (i % j == 0) break;
        if (j + 1 > sqrt(i)) x++;
      }
    cout << x << endl;
  }
}