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>

int main() {
    int i, k, v,an1,an2,suu;
    int MAX_V = 10000;
    int prime[MAX_V+1];
    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;   
            } 
        }
    }
   while(1){
        scanf("%d",&suu);
        if(suu != 0){
            for(k=2;k<=suu;k++){
            	if(prime[k-2]==1 && prime[k]==1){
        	    	an1=k-2;
        	    	an2=k;
            	}
            }
            printf("%d %d\n",an1,an2);
        }
        else{
    	    break;
        }
    }
    return 0; 
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int main(){
    
    ll n;
    while(cin>>n){
        ll ans=0;
        for(int i=3;i<=n;i+=2){
            int flag=0;
        for(int j=3;j<=sqrt(i);j+=2){
            if(i%j==0){
                flag=1;
                break;
            }
        }
            if(flag==0){
                ans++;
            }
    }
        cout<<ans+1<<endl;
        }
    
    
    
    
    
    
    return 0;
}

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

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

    return true;
}

int main()
{
    int num,i,count;

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

        if(isPrime(i))
            count++;
        }
    printf("%d\n",count);
    }
    return 0;
}

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

int main()
{
	int n = 0, x = 0;
	int countdata[1000];
	while (cin >> n) {
		if (n / 1000000 > 0) {
			int count = 0;
			for (int a = 2; a <= n; a++) {
				if (a % 2 != 0 && a % 3 != 0 && a % 5 != 0 && a % 7 != 0) 
					count++;
				if (a == 2 || a == 3 || a == 5 || a == 7)
					count++;
			}
			countdata[x] = count;
			x++;
		}
	}
	for (int a = 0; a < x; a++) {
		cout << countdata[a] << endl;
	}
	return EXIT_SUCCESS;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;



int main(){
	for(int n; cin >> n; ) {
		vi p(n + 1, 1);
		p[0] = p[1] = 0;
		int ans = 0;
		rep(i, n + 1) if (p[i]) {
			ans++;
			for (int j = i + i; j <= n; j += i) p[j] = 0;
		}
		cout << ans<< endl;
	}
	return 0;
}

C++: /*
 0…未確定
 1…素数
 2…素数でない
*/
#include <iostream>

using namespace std;

int main(){
    int num[1000000]={0}, b, a, n, c;
    for(int i=2;i<=1000;i++){
        if(num[i]==0){
            num[i]=1;
            b=1;
            while((a=(++b*i))<1000000) num[a]=2;
        }
    }

    while(cin >> n){
        c=0;
        for(int i=2;i<=n;i++) {
            if(num[i]==1||num[i]==0) c++;
        }
        cout << c << 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;
	while(cin >> n){
		int count = 0;
		for(int i = 0; i <= n; i++){
			if(b[i]){
				count ++;
			}
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
int main(void) {
    int i,j,n,ans=0,prime[1000000];
    prime[0]=0;prime[1]=0;
    for(i=2;i<1000000;i++){prime[i]=1;}
    for(i=2;i<1000000;i++){
        if(prime[i]==1){
            ans++;
            if(i<1000)for(j=i*i;j<1000000;j+=i)prime[j]=0;
        }
        prime[i]=ans;
    }
    while(scanf("%d",&n)!=EOF){printf("%d\n",prime[n]);}
    return 0;
}

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

int eratos(int n){
	bool isprime[n + 1];
	for(int i = 0; i <= n; i++)isprime[i] = true;
	isprime[0] = isprime[1] = false;
	for(int i = 2; i * i <= n; i++){
		if(isprime[i]){
			int j = i + i;
			while(j <= n){
				isprime[j] = false;
				j = j + i;
			}
		}
	}
	int counter = 0;
	for(int i = 0; i <= n; i++){
		if(isprime[i] == true)counter++;
	}
	return counter;
}

int main(){
	int n;
	while(cin >> n){
		cout << eratos(n) << endl;
	}
}

C++: #include "stdio.h"
#include "iostream"
using namespace std;

int main()
{
    int n,count=0,m=0,i,j;
    while(cin>>n)
    {
        for(i=2;i<=n;i++)
        {
            for(j=1;j<i;j++)
            {
                if(i%j==0)count++;
            }
            
            if(count==1)
            m++;

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

C++: #include<stdio.h>
int main ()
{
int n,m,cou;m=0;cou=0;
while(scanf("%d",&n)!=EOF)
{
for(int i=3;i<=n;i+=2){
for(int k=3;k<i;k+=2){
if(i%k==0){m++;break;}}
if(m==0)cou++;
m=0;
}
if(n==2)cou=1;
else if(n==1)cou=0;
else cou++;
printf("%d\n",cou);
cou=0;
}
return 0;
}

C++: #include <stdio.h>
const int MAX_V = 100000;
int prime[MAX_V+1],sum[MAX_V+2]={0};
int main(){
  int n;
  for(int i = 2;i <= MAX_V;i++){
    prime[i] = 1;
  }
  for(int i = 2;i * i <= MAX_V;i++){
    if(prime[i]){
      for(int k = 2* i;k <= MAX_V;k += i)
      prime[k]=0;
    }
  }
  for(int i = 2;i < MAX_V;i++){
    sum[i] +=sum[i-1]+prime[i];
  }
  while(1){
    scanf("%d",&n);
    printf("%d\n",sum[n]);
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main() {
  long n;
  vector<long> primes;
  primes.push_back(2);
  while (cin >> n) {
    for (int i = 3; i <= n; i += 2) {
      bool prime = true;
      for (long j : primes)
        if (i % j == 0) {
          prime = false;
          break;
        }
      if (prime) primes.push_back(i);
    }
    int x = 0;
    for (long j : primes)
      if (j <= n) x++;
    cout << x << endl;
  }
}

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

int main() {
	int n,yakusuu,sosuu;
	while (cin >> n) {
		sosuu = 0;
		for (int i = 1; i <= n; i++) {
			yakusuu = 0;
			for (int j = 1; j <= i; j++){
				if (i%j == 0)yakusuu++;
			}
			if (yakusuu == 2)sosuu++;
		}
		cout << sosuu << endl;
	}
	return 0;
}