Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

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


bool isPrime(int I)
{
	for(int i = 2; i < I; i ++){
		if(I % i == 0)
			return false;
	}
	return true;
}
void printPrime(int N)
{
	int total = 0;
	for(int i = 2; i <= N; i ++)
	{		
		if(isPrime(i) == true){
			total ++;
		}
	}
	cout<<total<<endl;
}


int main(){
	int n;
	while(cin>>n){
		printPrime(n);
	}
	
}

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 <cstdio>
#include <cstring>
#define MAXN 1000010
bool is_prime[MAXN];
int prime[MAXN];

void find(int n) {
    memset(is_prime,1,sizeof(is_prime));
    is_prime[0]=is_prime[1]=false;
    prime[0]=0;
    for(int i=2;i<=n;i++) {
        if(is_prime[i]) {
            prime[++prime[0]]=i;
            for(int j=2*i;j<=n;j+=i) is_prime[j]=false;

        }
    }
}


int bifind(int n) {
    int b=1,e=prime[0],mid;
    while(b<=e) {
        mid=(b+e)>>1;
        if(n==prime[mid]) return mid;
        //printf("%d %d %d\n",b,mid,e);
        else if(n>prime[mid]) {b=mid+1;}
        else {e=mid-1;}
    }
    return b-1;
}
int main() {
    int n;
    find(999999);
    //printf("%d\n",prime[0]);
    //printa(prime,prime[0]);
    while(scanf("%d",&n)!=EOF) {
         int pos=bifind(n);
         printf("%d\n",pos);
    }
}

C++: /*#include <stdio.h>
  int main(){
    int a,b,c,d,n,sum=0;
      while(scanf("%d",&n) != EOF){
       for(a=0;a<10;a++){
          for(b=0;b<10;b++){
             for(c=0;c<10;c++){
                for(d=0;d<10;d++){
                    if(a+b+c+d==n)
                        sum++;
                          }
                            }
                             }
                               }
                                printf("%d\n",sum);
                                 sum=0;
                                   }
return 0;
}*/#include <stdio.h>
  int main(){
   int i,j,n,hantei=0;
   int sum=0;
    while(scanf("%d",&n) != 0){
    for(i=2;i<=n;i++){
      for(j=2;j*j<=i;j++){
        if(i%j != 0 || i == j){
            hantei += 0;
               }else{
                  hantei += 1;
                    }
}
if(hantei == 0){
sum++;

}
hantei=0;
}
printf("%d\n",sum);
sum=0;
hantei = 0;
}
return 0;
}

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

#define maxPN 500000
#define PNs  1000100
int countPN = 0, countPNs = 0;
int PrimeNum[maxPN], temp;
bool PN[PNs];

bool IsPrimeNumber(int x);

void PrimeN(){
	int i, j;
	PrimeNum[0] = 2;
	PN[2] = true;PrimeNum[countPN++] = 2;
	PN[3] = true;PrimeNum[countPN++] = 3;
//	PN[5] = true;PrimeNum[countPN++] = 5;
	
	for(i = 6; i  < PNs;i+=6){
		if(IsPrimeNumber(i-1)){
			PrimeNum[countPN++] = i-1;
			PN[i-1] = true;//cout<<i-1<<endl;
		}
		if(IsPrimeNumber(i+1)){
			PrimeNum[countPN++] = i+1;
			PN[i+1] = true;//cout<<i+1<<endl;
		}
		countPNs = i+1;//cout<<i-1<<" "<<PN[i-1]<<endl;
	}
}

bool IsPrimeNumber(int x){
	//if(x == 2 || x == 3) return true;
	//if(x <= 4 || x%2 == 0 || x%3 == 0)   return false;
	//if(x < countPNs) return PN[x];
	for(int i = 0; PrimeNum[i] * PrimeNum[i] <= x; i++)
		if(x%PrimeNum[i] == 0)return false;
	return true;
}


int main(){
//	clock_t start, end;
	int n = true, counta;
//	start = clock();
	PrimeN();
	cout<<PrimeNum[countPN-1]<<" "<<countPNs<<endl;
//	cout<<clock()-start<<"ms"<<endl;
	
	while(cin>>n){
		counta = 1;
		
		
		//cout<<(IsPrimeNumber(n)?"yes":"no")<<endl;
	//	start = clock();
		//cout<<IsPrimeNumber(n)<<endl;
		for(int i = 1; i <= n; i+=2){
			if(PN[i])counta++;
		//	cout<<i<<" "<<PN[i]<<endl;
		}
		if(n == 1) counta = 0;
		cout<<counta<<endl;
	//	cout<<clock()-start<<"ms"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
bool flag[10000001];
 
int main(){
    int n=0,ans=0;
    for(int i=0;i <= 1000000;i++){
        if(i<=1)flag[i]=false;
        else flag[i]=true;
    }
    for(int i=2;i <= 1001 ;i++){
        if(flag[i]==true){
            for(int j=i*2 ; j<=1000000 ; j=j+i){
                flag[j] = false;
            }
        }
    }
    while(cin>>n){
        ans=0;
        for(int i=0;i <= n;i++){
            if(flag[i]==true){
                ans++;
            }
        }
        cout<<ans<<endl;
    }
}

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

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


int main(){
	bool work[MAX + 1];
	int num, ans = 0;

	// 初期化
	for(int i = 6; i <= MAX; i++){
		for(int j = 2; j < (i / 2); j++){
			if (i % j == 0){
				work[i] = false;
				break;
			}else{
				work[i] = true;
			}
		}
	}
	work[0] = false;
	work[1] = false;
	work[2] = true;
	work[3] = true;
	work[4] = false;
	work[5] = true;

	// 出力
	while(cin >> num){		
		for(int i = 0; i <= num; i++){
			if(work[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
}

C++: ///bismillah_hir_rahmanir_rahim
///GALIB-2015331528

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

int prime[1000000];
int main()
{
    int n,c;
    cin>>n;
    if(n==1){
        cout<<"0"<<endl;
        return 0;
    }

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

    cout<<c<<endl;




    return 0;
}

C++: #include<stdio.h>

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

int main(void){
	int n,cnt=0;
	scanf("%d",&n);
	for(int i=2;i<n;i++){
		if(p(i)){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

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

int main() {
	// your code goes here
	int nu[30];
	int num;
	int count = 0;
	int max = 29;
	for(int x=0;x<30;x++){
		nu [x] = -1;
		cin >> nu[x];
		if (nu[x] == -1) {
			max = x;
			break;
		}
	}
	for (int y=0;y<max;y++) {
		num = nu[y];
		count = 0;
		
		for (int i = 1;i<=num;i++) {
		if(i%2==0) {
			//cout <<"2: "<<i<<endl;
			count ++;
			continue;
		}
		if(i==5||i==7) continue;
		for (int j=9;j<(int)sqrt(i)+1;j=j+2) {
			if (i%j==0) {
				count ++;
				//cout <<"i: "<<i<<" j: "<<j<<endl;
				break;
			}
		}
	}
	cout << (num-count) <<endl;
	//cout << endl;
	}
	return 0;
}