Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

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
}

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

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

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

#define N 1000000L
bool num[N];

void furui(){
  long int i;
  int divide;
  int rt = 1000;
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = (long int) divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(void){
  int c, i, j;
  long int k;
  char buf[7];
  long int n;
  long int count;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0; ;i++){
      c = getchar();
      if(c == EOF || c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == 1) count++;
    }
    std::cout << count << std::endl;
    if(c == EOF) break;
  }
  return 0;
}

C++: #include<stdio.h>
#include<math.h>
int main()
{
    long long int n,i,j,k,l,number[1000000];

    while(scanf("%lld",&n)!=EOF)
    {
       if(n==0 || n==1) printf("0\n");
       else if(n==2) printf("1\n");
       else if(n==3) printf("2\n");
       else
       {
            k=sqrt(n);
            l=1;
            for(i=0;i<n;i++)
            {
                number[i]=i+1;
            }

            for(j=2;j<=k;j++)
            {
                for(i=1;i<n;i++)
                {
                    if(number[i]%j==0)
                    {
                        number[i]=0;
                    }
                }
            }
            for(i=1;i<n;i++)
            {
                if(number[i]!=0) l++;
            }
            printf("%lld\n",l);
        }
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int a,b,c=0;
	int flg=0;
	while(cin>>a){
		for (int A=2;A<=a;A++){
		flg=0;
			for (int B=2;B<=A;B++){
				b=A%B;
				if (A==B){
					c++;
					break;
				}
				if (b==0) break;
			}
		}
		cout<<c<<endl;
		c=0;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

bool pr(int p){
    int x=2;
    while(x*x<=p){
        if(p%x==0){
            return false;
        }
        x++;
    }
    return true;
}


int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        int ans=0;
        for(int i=2;i<=n;i++){
            if(pr(i)){
                ans++;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

using namespace std;

const int N = 1000010;
bool isPrime[N];

void sieve(){
    for(int i=2;i<N;i++) isPrime[i] = true;
    for(int i=2;i*i<N;i++){
        if(not isPrime[i]) continue;
        for(int j=i*i;j<N;j+=i){
            isPrime[j] = false;
        }
    }
}

int main(){
    vector<int> C(N);
    sieve();
    C[0] = 0;
    for(int i=1;i<N;i++){
        if(isPrime[i]){
            C[i] = C[i-1] + 1;
        }else{
            C[i] = C[i-1];
        }
    }
    int n;
    while(cin >> n){
        cout << C[n] << endl;
    }
    return 0;
}

C++: #include <stdio.h>

#define MAX (100000)

int main(void)
{
	int prime[MAX + 1] = {1};
	int n;
	int ans;
	int i;
	char str[8];
	
	for (int i = 0; i <= MAX; i++){
		prime[i] = 1;
	}
	
	prime[0] = prime[1] = 0;
	i = 0;
	while (i * i <= MAX){
		while (prime[++i] != 1 && i * i <= MAX);
		//printf("%d ", i);
		for (int j = 2; j * i <= MAX; j++){
			//printf("%d\n", i * j);
			prime[i * j] = 0;
		}
	}
	
	while (fgets(str, 7, stdin)){
		sscanf(str, "%d", &n);
		
		ans = 0;
		for (int i = 2; i <= n; i++){
			if (prime[i] == 1){
				ans++;
			}
		}
	
		printf("%d\n", ans);
	}
	
	return (0);
}

C++: #include <iostream>
using namespace std;
int main(){
	int a,b,c=0;
	int flg=0;
	while(cin>>a){
		for (int A=2;A<=a;A++){
		flg=0;
			for (int B=2;B<=A;B++){
				b=A%B;
				if (A==B){
					c++;
					break;
				}
				if (b==0) break;
			}
		}
		cout<<c<<endl;
		c=0;
	}
	return 0;
}

C++: int main(void)
{
	int data,i,j,k=0,l=0,kai[100]={0},s[100000]={0};

	while(scanf("%d",&data) != EOF)
	{
		if(data<=1)
		   kai[k]=0;
		else
		{
			for(i=2;i<=data;i++)s[i]=i;

		    i=2;
			while(i*2<data)
			{
			  if(s[i] != 0)
			  {  
				j=2;
				while(j*i<=data)
				{
					s[j*i]=0;
					j+=1;
				}
			  }
			  i+=1;
			}

			
			for(i=2;i<=data;i++)
			{	
				if(s[i]!=0)
				{
					kai[k]+=1;
				}
			}
		}
		k+=1;
	}

  for(j=0;j<k;j++)
    printf("%d\n",kai[j]);
  return 0;
}

C++: #include<stdio.h>


int main(){
	int n;
	bool data[10000000];

	int i,j;
	data[0]=data[1]=0;
	for(i=2;i<10000000;i++){
		data[i]=1;
	}

	for(i=0;i<10000000;i++){
		if(data[i]==1){
			for(j=i+i;j<1000000;j=j+i){
				data[j]=0;
			}
		}
	}


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

C++: #include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
bool isPr(int n);
int main(){
    int a[1000000],n;
    memset(a,0,sizeof(a));
    a[2]=1;
    for(int i=3;i<1000001;i++)
        a[i]=a[i-1]+isPr(i);
    while(cin>>n){
        cout<<a[n]<<endl;
    }
    return 0;
}
bool isPr(int n){
    for(int i=sqrt(n)+1;i>1;i--){
        if(!(n%i)){
            return 0;
        }
    }
    return 1;
}

C++: #include <stdio.h>

const int MAX_V=1000000;
int prime[MAX_V+1];//1?´???°,0?´???°??§??????
int sum[MAX_V+1];
int main(){
    int i,k,v;
    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?????\???????????°????´???°??§??????
            }
        }
    }
    for(i=0;i<MAX_V+1;i++){
        sum[i+1]=sum[i]+prime[i];
    }
    while(scanf("%d",&v)!=EOF){
        printf("%d\n",sum[v+1]);
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int x = 1000000;
	int p[x],q[x];
	for(int i=2;i<x;i++) p[i] = 0;
	for(int i=2;i<x;i++){
		if(q[i]==0) for(int j=2;j<x/i;j++) q[i*j] = 1;
	}
	int c = -1;
	for(int i=2;i<x;i++){
		if(q[i]==0){
			c++;
			p[c] = i;
		}
	}
	int n;
	while(cin >> n){
		int a = 0;
		for(int i=0;i<c;i++){
			if(p[i]>n) break;
			a++;
		}
		cout << a << endl;
	}
}

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

#define LIM 1000000
using namespace std;

void prime();

vector<int> prime_map;

int main(){
  int num, i=0,j=0;
  vector<int> count;
  prime();
  cout<<"plese"<<endl;
  while(cin){
    cin>>num;
    i=0;
    while(prime_map[i]<=num){
      i=i+1;
    }
    count.push_back(i);
    j++;
  }

  i=0;
  while(i<j){
    cout<< count[i]<<endl;
    i++;
  }
}

void prime(){
  bool judge;
  for(int i = 2; i <= LIM;i++){
    judge=1;
    for(int j= 2; j < i/2; j++){
      if(i%j == 0){judge = 0;
 break;
}
    }
    if(judge == 1)prime_map.push_back(i);
  }
}

C++: 
#include<iostream>
using namespace std;
int n;
bool isPrime(int a){
	int i;
	for (i = 2; i < a; ++i){
		if (a%i == 0){
			return false;
		}
	}
	return true;
}
int main()
{
	while (cin >> n){
		for (int i = 2; i <= n; ++i){
			if (isPrime(i))
				cout << i << endl;
		}
	}
	return 0;
}