Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		input := nextInt()
		fmt.Println(IsPrime(input))
	}
}

func IsPrime(num int) int {
	eratos := make([]bool, num+1)
	c := 0
	for i := 2; i < len(eratos); i++ {
		if eratos[i] == false {
			c++
			eratosCalc(i, eratos)
		}
	}
	return c
}

func eratosCalc(primeNum int, eratos []bool) {
	for i := primeNum * primeNum; i < len(eratos); i += primeNum {
		eratos[i] = true
	}
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

C++: #include <stdio.h>
#include <math.h>
int sosuu(int x){
    int n,m,sosuu;
    sosuu=x-1;
    for(n=2;n<=x;n++){//nは素数を調べる。入力された数字まで１からスライドしていく。
        for(m=2;m<n;m++){//mはnが素数かどうか調べる。素数かどうかをnより小さい数字で数えていく。2からなのは2から素数だから。1はふくめない。
            if(n%m==0){//素数じゃなかったら、つまり割り切れてしまったら。
                sosuu--;
            }
            
            if(n%m==0) break;
        }
    }
    if(x==1||x==0) sosuu=0;
    return sosuu;
}

int main ( void ) {
    int s,result;
    while(scanf("%d",&s)!=EOF){
        result = sosuu(s);
        printf("%d\n",result);
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
    vector<int> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;

      v[0]=false;
      v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]==true){
        for(int j = i;j<MAX;j=j*j){
         v[j]=false;
       }
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())return 0;
      cout << v[a]<<endl;
    }
}

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

using namespace std;

int A[1000];
int Pream(int n)
{
	int kusa = (int)sqrt((double)n);
	int mama = 0;

	for (int i = 0; i < n; i++)
		A[i] = 1;  // ??¨????????°???1????????????
	A[0] = 0;    // 1????´???°??§?????????

	for (int i = 1; i < kusa; i++) {
		if (A[i] == 1)   // prime[i]????´???°??????
		{
			for (int j = (i + 1); (i + 1) * j <= n; j++)
				A[(i + 1) * j - 1] = 0;  // ?´???°????????°????´???°??§?????????
		}
	}
	for (int i = 0; i < n; i++)
		if (A[i] == 1)  // 1????????£???????????????????´???°
			mama++;

	return mama;
}

int main()
{
	int n;
	cin >> n;
	while (n != -1)
	{
		cout << Pream(n) << endl;
		cin >> n;
	}
	return 0;
}

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

#define MAX 1000000
int a[MAX];

int main()
{
	int n;
	a[0] = a[1] = 0;
	a[2] = 1;
	a[3] = 2;
	for (int i = 4; i < MAX; i++)
	{
		bool ok = true;
		for (int j = 2; j < sqrt(i) + 0.1; j++)
		{
			if (i % j == 0)
			{
				a[i] = a[i - 1];
				ok = false;
				break;
			}
		}
		if (ok)
			a[i] = a[i - 1] + 1;
	}

	while (cin >> n)
		cout << a[n] << endl;
	
	return 0;
}

C++: #include <iostream>
using namespace std;
const int maxn = 1000000;
int dp[maxn];
bool ar[maxn];
int main()
{
	for(int i = 2;i<=maxn;i++)
	{
		if(!ar[i])
		{
			for(int j = 2;j*i<maxn;j++)
				ar[i*j] = true;
		}
		dp[i] = dp[i-1] + !ar[i];
	}
	for(int n;cin >> n;)
		cout << dp[n] <<endl;
	return 0;
}

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

C++: #include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int n;

	while (cin >> n, n != EOF){
		int pn = 0;
		for (int i = 2; i <= n; i++){
			bool flag = true;
			for (int j = 2; j <= n; j++){
				if (i % j == 0 && i != j){
					flag = false;
					break;
				}
			}
			if (flag) pn++;
		}
		
		cout << pn << endl;
	}

	return 0;
}

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

int main() {
	int n, count;
	bool *data;

	while (cin >> n) {
		data = new bool[n+1];
		count = 0;
		data[0] = data[1] = false;
		for (int i = 2;i <= n;i++) {
			if (data[i]) {
				count++;
				for (int j = i + 1;j <= n;j += j) {
					data[j] = false;
				}
			}
		}
		cout << count << endl;
		delete[] data;
	}
	return 0;
}

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

int main()
{
	int n;
	int a[MAX];
	int counter;
	
	a[0] = 0;
	a[1] = 0;
	for (int i = 2; i < MAX; i++) {
		a[i] = 1;
	}
	
	int j = 2;
	while (j < MAX) {
		if (a[j] == 0) {
			j++;
		} else {
			for (int k = j *2; k < MAX; k += j)
				a[k] = 0;
			j++;
		}
	}
	
	while (cin >> n) {
		counter = 0;
		for (int i = 2; i <= n; i++)
			if (a[i])
				counter++;
		cout << counter << "\n";
	}
		
	return 0;
}

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

using namespace std;

int sosuu(int n);

int main(){
    int n=0;
    int num=0;
    int a[30][2]={0};
    int max=0;
    while(scanf("%d",&n)!=EOF){
        if(max<n){
            max=n;
        }
        a[num][0]=n;
        num++;
    }
    
    int b[max];
    int c[max];
    int so=0;
    for(int i=0; i<=max; i++){
        b[i]=i;
    }
    b[1]=0;
    
    for(int i=2; i<sqrt(max); i++){
        if(b[i]=!0){
            for(int j=i+1; j<=max; j++){
                if(j%i==0){
                    b[j]=0;
                }
        }
        }
    }
    
    for(int i=0; i<=max; i++){
        if(b[i]!=0){
            c[so]=i;
            so++;
        }
    }
    
    
//    for(int j=0; j<num; j++){
//        cout<<a[j][0]<<"\n";
//    }
//    
//    for(int j=0; j<=so; j++){
//        cout<<c[j]<<"\n";
//    }
    
    
    
    
    for(int i=0; i<num; i++){
        for(int j=0; j<so; j++){
            if(c[j]<=a[i][0]){
                a[i][1]++;
            }else{
                j=so;
            }
        }
    }

    
    for(int j=0; j<num; j++){
        cout<<a[j][1]<<"\n";
    }
    
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int prime[1000005],cur;
bool isprime[1000005];
int main()
{
	isprime[1]=1;
	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>
#include <vector>
using namespace std;
vector <int> wow(1000001);

bool prime(int m){
	if(m < 2)return false;
	if(m == 2)return true;
	if(m%2 == 0)return false;

	for(int i = 3; i*i <= m; i += 2){
		if(m%i == 0)return false;
	}
		return true;
}

int main(){

	for(int i = 0; i < 1000001; ++i){
	if(prime(i)){
					wow[i] = 1;
				}else{
					wow[i] = 2;
				}
	}


	int n;
	
	while(cin >> n){
		int a=0;
		for(int i = 1; i <= n; ++i){
		if(wow[i] == 1){
				++a;
			}
	}
		cout << a << '\n';
	}
}

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

int main()
{
	int n,i,j,count,pnum;
	while(cin >> n){
		/* ????????? */
		count=0;
		pnum=0;
		
		
		for(i=n; i>=2; i--){
			for(j=1; j<=i; j++){
				if(i%j==0) count++;	//i--????´???°?????°???????????????
			}
			if(count==2) pnum++;
			count=0;
		}
		cout << pnum << endl;
	}
	
	return 0;
}