Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [31]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>
#include<vector>
#include<cmath>
using namespace std;

int main(){
    int max = 1000000;
    vector<int> prime(max, 1);
    //ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
    
    for(int i = 0; i < max; i++){
        prime[i] = 1;
    }
    prime[0] = prime[1] = 0;
    for(int i = 2; i <= max; i++){
        if(prime[i] == 1){
            for(int j=i+i; j <= max; j+=i){
                prime[j] = 0;
            }        
        }
    }
    int n;
    while(cin >> n){
        int ans = 0;
        for(int i=0; i <= n; i++){
            if(prime[i] == 1){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <iostream>
#define rep(i,n) for(int i = 2; i <= (n); ++i)
using namespace std;
int n;
bool p[1000000];
int main() {
	rep(i,1000) {
		int k = i;
		if(!p[k]) {
			while(k < 1000000) {
				k += i;
				p[k] = true;
			}
		}
	}
	while(scanf("%d\n", &n) != EOF) {
		int count = 0;
		rep(i,n) {
			if(!p[i]) count++;
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
int p(long x)
{
    long i,j=sqrt(x),k=1;
    for(i=2;i<=(j);i++)
    {
        if(x%i==0){
            k=0;
            //return k;
        break;

        }
    }
    if(k==1)return 1;
    else return 2;
}
using namespace std;
int main()
{
    double a,b,c,i,n,s=0;

    cin>>n;
    //a=sqrt(n);
    for(i=2;i<=n;i++)
    {
        if(p(i)==1){s++;}
    }
    cout<<s<<endl;



    return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int d=0,i,j,s[100000],x;

	for(i=2;i<=100000;i++)
		s[i]=1;

	while((scanf("%d",&d))!=EOF)
	{
		x=0;
	    for(i=2;i<=d;i++){
	       if(s[i]==1){
		     for(j=i*2;j<=d;j+=i)
			   s[j]=0;
		   }
	    }  
		if(d<=1){
			printf("%d\n",0);
		}
		else
		{
		for(i=2;i<=d;i++){
			x+=s[i];
		}
		printf("%d\n",x);
		}
	}
  return 0;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int prime[1000005],cur;
bool isprime[1000005];
int main()
{
	for(int i=2;i<1000000;i++)
		if(!isprime[i])
		{
			prime[cur++]=i;
			for(long long j=1LL*i*i;j<1000000LL;j+=1LL*i)
				isprime[j]=1;
		}
	int n;
	while(~scanf("%d",&n))
		printf("%d\n",lower_bound(prime,prime+cur,n)-prime+(!isprime[n]));
	return 0;
}

C++: #include<iostream>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

const int MAX = 1000000;

bool prime[MAX];
int c[MAX];

int main() {
  rep (i, MAX) prime[i] = true;
  prime[0] = prime[1] = false;
  for (int i = 0; i * i <= MAX; ++i) {
    if (prime[i]) {
      for (int j = i * i; j < MAX; j += i) prime[j] = false;
    }
  }
  rep (i, MAX - 1) c[i + 1] = c[i] + (prime[i + 1] ? 1 : 0);
  int n;
  while (cin >> n) {
    cout << c[n] << endl;
  }
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <string.h>

#pragma warning(disable:4996)

int main()
{
	int nCnt,nCnt2,In,Total,Count;

	Total = 0;

	scanf("%d", &In);

	for (nCnt = 2; nCnt <= In; nCnt++)
	{
		Count = 0;
		for (nCnt2 = nCnt; nCnt2 >= 2; nCnt2--)
		{
			if (nCnt%nCnt2 == 0)
			{
				if (nCnt != nCnt2)
					Count++;
			}
		}
		if (Count == 0)
			Total++;
	}

	printf("%d\n", Total);

	return 0;
}

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

C++: #include<iostream>

using namespace std;

int main(void){
	
	long int n,f,k,i;
	int count;
	bool chk;
	scanf("%d",&n);
		count=0;
		for(i=2;i<=n;i++){
		
			chk=0;
			f=i/2;
			k=2;
		
			while(f>=k){
				if((i%k)==0){
					chk=true;
					break;
				}
				k++;
			}
		
			if(chk==false){
				count++;
			}
		}
		cout<<count<<endl;
	
}

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

#define MAX 1000000
int prime[MAX];

int main()
{
	int number,count=0;
	prime[0] = prime[1] = 0;

	for(int i=2;i<MAX;i++)
	{
		prime[i] = 1;
	}
	for(int i=2;i<1001;i++)
	{
		if(prime[i])
		{
			for(int j=2*i;j<MAX;j += i)
			{
				prime[j] = 0;
			}
		}
	}

	while(cin >> number)
	{
		count = 0;
		for(int i=2;i<=number;i++)
		{
			count += prime[i];
		}
		printf("%d\n",count);
	}

	return 0;
}

C++: #include <cstdio>

int main(){
	int n;
	static bool c[1000000]={true};
	static int t[1000000];//t[0] = 0;
	for(int i = 2;i < 1000000;i++){
		if(!c[i]){
		for(int j = 2;i*j < 1000000;j++){
			c[i*j] = true;
		}
		}
		t[i]=t[i-1]+!c[i];
	}
	/*for(int i = 1;i < 1000000;i++){
		if(c[i])t[i]=t[i-1];
		else t[i] = t[i-1]+1;
	}*/
	for(int n;scanf("%d", &n);n++){
		printf("%d\n", t[n]);
	}
	
	while(scanf("%d", &n)){
		printf("%d\n", t[n+1]);
	}
	return 0;
}

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

int main(){
    int n;
    int result;
    int i, j;
    bool flug = false;

    while(cin >> n){
        for(i=2; i<n; i++){
            for(j=2; j<(int)sqrt(i)+1; j++){
                if(i % j == 0){
                    flug = true;
                    break;
                }
            }
            if(!flug) result++;
            flug = false;
        }

        cout << result << endl;
        result = 0;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;
int TestCase;



int main()
{
   while(cin >> TestCase)
   {
       int PrimeNumbers = 0;
       if(TestCase >= 2)
       {
           PrimeNumbers++;
       }
       for(int Sample = 3; Sample <= TestCase; Sample+=2)
       {
           if(Sample > 10)
           {
                if(Sample%3 != 0 && Sample%5 != 0 && Sample%7 != 0)
               {
                   PrimeNumbers++;
               }
           }
           else
           {
               if(Sample != 9)
               {
                   PrimeNumbers++;
               }
           }

       }
       cout << PrimeNumbers << endl;
   }

}

C++: #include<stdio.h>
const int MAX_V = 100;
int prime[MAX_V+1];
int main() {
  int i, k;
  for(i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++) {
    if(prime[i]) {
      for(k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }

  int right;
  int sum[MAX_V+1] = {0};
  sum[1] = 0;
  for(i = 1; i < MAX_V+1; i++){
    if(prime[i] == 1){
      sum[i + 1] = sum[i] + 1;
    }else{
      sum[i + 1] = sum[i];
    }
  }
  while(scanf("%d", &right) != EOF){
    printf("%d\n", sum[right + 1]);
  }
  return 0;
}

C++: #include <iostream>
#include <math.h>

int prime[1000000];


bool isPrime(int n) {
  int x = (int)sqrt(n);
  for (int i = 3; i <= x; i += 2) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}


void get_prime(int max_num) {
  int primecount = 1;
  prime[2] = primecount;
  for (int i = 3; i <= max_num; i += 2) {
    if (isPrime(i))
      prime[i] = ++primecount;
    else
      prime[i] = primecount;
  }
}


int main () {
  int ns[31];
  int i = 0, max_num;
  while (std::cin >> ns[i]) {
    max_num = std::max(max_num, ns[i]);
    if (ns[i] % 2 == 0)
      ns[i] --;
    i ++;
  }
 
  return 0;
}