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<iostream>

using namespace std;

int main(){
  int n,flag=1,sum = 0;

  while(cin >> n){
    if(n == 1) cout << 0;

    for(int i=2; i <= n; i++){
      for(int j=2; j < i; j++){
	if(i%j == 0 ) flag = 0;
      }
      if(flag == 1) sum++;
      flag = 1;
    }
    cout << sum <<endl;
    sum = 0;
  }
}

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

int main()
{
	int counter=0,n,flag;
	
	while(cin>>n)
	{
		if(n<=1) 
		{
			cout<<'0'<<endl;
			break;
		}

		for(int i=3;i<=n;i+=2)
		{
			flag=1;
			for(int j=3;j<=sqrt(n);j+=2)
				if(i%j==0)
				{
					flag=0;
					break;
				}
			if(flag==1)
				counter++;
		}
		cout<<counter<<endl;
	}
}

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

int main()
{
	int n, i, j, count;

	while(scanf("%d", &n) != EOF){
		count = n - 1;

		for (i = 2; i <= n; i++){
			for (j = 2; j <= sqrt(i); j++){
				if(i%j == 0) {count--; break;}
			}
		}

		printf("%d\n", count);
	}

	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	long long n, a, b,c;
	b = 0;
	while (cin >> a) {
		for (c = 1; c <=a; c++) {
			for (int j = 2; j*j <= c; j++) {
				if (c%j == 0) {
					b++;
					break;
				}
			}
		}
		cout << a - b - 1 << endl;
		b = 0;
	}
	return 0;
}

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

int main() {
	int n;
	while(cin >> n && n != EOF) {
		bool* prime = new bool[n+1];
		int count = 0;
		for(int i = 2; i <= n; ++i) {
			prime[i] = true;
		}
		prime[0] = prime[1] = false;
		
		for(int i = 0; i <= n; ++i) {
			if(prime[i]) {
				for(int j = 2 * i; j < n; j += i) {
					prime[j] = false;
				}
			}
		}
		
		for(int i = 0; i <= n; ++i) {
			if(prime[i]) {
				count++;
			}
		}
		
		cout << count << endl;
		delete[] prime;
	}
}

C++: #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define N 999999
char num[N];
void furui(){
  int i, divide;
  for(i = 0; i < N; i++){
    num[i] = 1;
  }
  num[0] = 0;
  num[1] = 0;
  for(divide = 2; divide <= sqrt(N); divide++){
    if(num[divide] == 0) continue;
    for( i = 0; i < N; i++){
      if(i % divide == 0){
        num[i] = 0;
      }
    }
    num[divide] = 1;
  }
}

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

  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);
    for(i = 1; i <= n; i++){
      if(num[i] == 1) count++;
    }
    printf("%ld\n", count);
    if(c == EOF) break;
  }
  return 0;
}

C++: #include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> prime;
void init(){
	for(int i=2;i<999999;i++){
		bool isprime=true;
		for(vector<int>::iterator p(prime.begin());p!=prime.end();p++){
			if(i%*p==0){
				isprime=false;
				break;
			}
		}
		if(isprime){
			prime.push_back(i);
		}
	}
}
int main(){
	int n;
	init();
	while(cin>>n){
		cout<<lower_bound(prime.begin(),prime.end(),n)-prime.begin()+1<<endl;
	}
	return 0;
}

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

bool isp[max];
int ans[max]={};

void sieve(){
	for(int i=0;i<max;i++)isp[i]=true;
	for(int i=2;i<max;i++){
		if(isp[i]){
			ans[i]++;
			for(int j=2*i;j<max;j+=i)isp[j]=false;
		}
	}
	for(int i=1;i<max;i++)ans[i]+=ans[i-1];
	return;
}

int main()
{
	int n;

	sieve();
	while(cin>>n)cout<<ans[n]<<endl;

	return 0;
}

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

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

int prime(int data){
	int i;
	if(data%2 == 0){
		return 0;
	}
	for(i = 3;i < sqrt(data);i+=2){
		if(data%i == 0){
			return 0;
		}
	}
	return 1;
}

int main(void){
	int data,cnt=0,i;
	while(std::cin >> data){
		if(data > 1)cnt = 1;
		for(i=3;i<=data;i++){
			if(prime(i)){
				cnt++;
			}
		}
		std::cout << cnt << std::endl;
	}
}

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

int main()
{

	int n;
	while (cin >> n) {
		int C = 0;
		bool prime[1000000] = { 0 };
		// 0????´???°
		prime[1] = 1;
		prime[2] = 0;

		for (int j = 2; j * j <= n; j++) {
			if (prime[j] ==0) {
				for (int k = 2; k*j <= n; k++) {
					prime[j*k] = 1;
				}
			}
		}
		for (int i = 1; i <= n; i++) {
			if (prime[i] == 0)
				C++;
		}
		cout << C << endl;
	}
	return 0;
}

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

int main(void)
{
    int count=0;
    int i=1;
    int n=1;
    int number;
    int a[30]={0};
    int j=0;
    // insert code here...
    while (cin >> number){
        while (n <= number){
            if(n == 1) {n++; continue;}
            while (i <= n) {
                if(i == 1) {i++; continue;}
                if(i == n) count++;
                if(n % i == 0) break;
                i++;
            }
            n++;
            i=1;
            
        }
        i=1;
        n=1;
        j++;
        a[j] = count;
    }
    
    for(int i=0;i<j;i++){
        cout << a[j] << endl;
    }
    return 0;
}

C++: /*
	大号水?，拿来?手
*/
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;

int Find_Number (int x)
{
	int cnt = 0;
	for (int i=2;i<=x;i++)
	{
		bool flag = false;
		for (int j=2;j<=sqrt((double)i);j++)
		{
			if ( i % j == 0)
			{
				flag = true;
				break;
			}
		}
		if (flag == false )
		{
			cnt++;
		}
	}
	return cnt;
}

int main ()
{
	int N;
	scanf("%d",&N);
	cout<<Find_Number (N)<<endl;
	return 0;
}

C++: #include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cctype>
#include <stdlib.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <iterator>

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define ss(ch) scanf("%s",ch)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define ps(ch) printf("%s",ch)
#define NL printf("\n")
#define debug(x) printf("wow %d !!\n",x)

typedef long long LL;

using namespace std;

bool array[1000010];
int ans[1000010];
int main()
{
    int i,j;
    array[1]=1;
    for(i=2; i*i<=1000005; i++)
    {

        if(!array[i])for(j=i*i; j<=1000005; j=j+i)array[j]=1;
    }
    int cnt=0;
    rep(i,1000005)
    {
        if(array[i]==0)cnt++;
        ans[i]=cnt;
    }
    int n;
    while(si(n) !=EOF)
    {
        pi(ans[n]);
        NL;
    }
    return 0;
}

C++: #include<cstdio>
#include<cstring>
int main(){
 int n,cnt=0;
 scanf("%d",&n);
 int a[n+1];
 memset(a,-1,sizeof(int)*(n+1));
 for(int i=2;i<=n;i++){
 if(a[i]==-1){ cnt++;
 for(int j=i;j<=n;j=j+i) a[j]=0;}
}
return 0;
}