Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		flag := false
		count := 0

		for i := 2; i <= num; i++ { //1を除く入力値以下の数字
			for j := i - 1; j >= 1; j-- {
				if i%j == 0 && j != 1 {
					flag = true
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

C++: int main(){
	int i , j , n , pn , cn=0;
	
	while(cin>>n){
		pn=1;
		for(i=3 ; i<=n ; i++){
			for (j=2 ; j<i ; j++){
				if (i%j==0) goto skip;
			}
			pn++;
			skip:;
		}
		if(n==0 || n==1 ) {
			cout << 0 << endl;
		} else {
			cout << pn << endl;
		}
		cn++;
		if(cn>=30) break;
	}
	return 0;
}

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

C++: #include <iostream>
#include <cmath>
using namespace std;
// have you mooed today?
bool isprime(int& num)
{
    static int c;
    static int max;
    max = sqrt(num) + 2;
    if(num == 2) return true;

    for(c=2; c < max; c++)
        if(num % c ==0) return false;
    return true;
}

main()
{
    int ans;
    int buff;
    while(cin >> buff)
    {
        ans  = 0;
        for(int d =2; d <= buff; d++)
        {
            if(isprime(d)) ans++;
        }
        cout << ans << endl;
    }
}

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

#define Max 1000000

int isPrime[Max];

int main(){
    int num;
    int i;

    isPrime[0] = isPrime[1] = 0;
    for(i = 2; i < Max; ++i){
        isPrime[i] = 1;
    }
    
    for(i = 3; i < Max; ++i){
        if(i % 2 == 0){
            isPrime[i] = 0;
        }
    }

    for(i = 4; i < Max; ++i){
        if(i % 3 == 0){
            isPrime[i] = 0;
        }
    }

    for(i = 6; i < Max; ++i){
        if(i % 5 == 0){
            isPrime[i] = 0;
        }
    }

    for(i = 8; i < Max; ++i){
        if(i % 7 == 0){
            isPrime[i] = 0;
        }
    }

    while(cin >> num){
        int count = 0;
        for(i = 0; i <= num; ++i){
            if(isPrime[i] == 1){
                count++;
            }
        }
        cout << count << endl;
    }
}

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

int main(){
    vector<int> prime;
    int n;
    for(int i=2;i<1000000;i++){
        bool isprime=true;
        for(int j=2;j<=sqrt(i);j++){
            if(i%j==0){
                isprime=false;
                break;
            }
        }
        if(isprime) prime.push_back(i);
    }
    while(cin >> n){
        for(int i=0;i<prime.size();i++){
            if(prime[i]>n){
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

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

int main(){
	int n;
	bool num[MAX_N];
	for(int i=0;i<MAX_N;i++) num[i]=false; 

	while(cin>>n){
		int ans=0;
		for(int i=2;i<=n;i++){
			if(num[i]) continue;
			for(int j=2;j<=n/i;j++) num[i*j]=true;
			ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

int prime[10000];
bool is_prime[1000000];

int sosuu(int n){
    int p=0;
    for (int i=0; i<=n; i++)
        is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for (int i=2; i<=n; i++) {
        if(is_prime[i]){
            prime[p++]=i;
            for (int j=i*2; j<=n; j+=i) {
                is_prime[j]=false;
            }
        }
    }
    return p;
}

int main(void){
    int n;
    while(cin>>n)
    cout<<sosuu(n)<<endl;
    return 0;
}

C++: #include<iostream>
using namespace std;
int PrimeNum(int n){
  for(int i = 2;i <= n;i++){
    if(i == n){
      return 1;
    }
    if(n % i == 0){
      return 0;
    }
  }
}
int main(){
  int n,num;
  for(cin >> n;n != 0;cin >> n){
    num = 0;
     for(int k = 2;k <= n;k++){
       if(PrimeNum(k) == 1){
	 num = num +1;
       } 
     }
     cout << num;
  }
}

C++: #include <iostream>
#include <cmath>
using namespace std;
bool whether(int num);
int count(int num);

int main(){
    int n;
    while(cin>>n){ cout <<count(n)<<endl; }
    return 0;
}

bool whether(int num){//if num is prime, 1
    int s=sqrt(num);
    for(int i=3; i<=s; i+=2){
        if(num%i==0){ return 0; }
    }
    return 1;
}

int count(int num){
    int a=1;
    if(num<=2){ return num-1; }
    for(int i=3; i<=num; i+=2){
        if(whether(i)){ a+=1; }
    }
    return a;
}

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

int main(void){
  int n;
  while(cin >> n){
    if(n < 3){
      if(n < 2){
	cout << 0 << endl;
      }else{
	cout << 1 << endl;
      }
    }
    int ans = 0;
    for(int i = 3; i <= n; i += 2){
      bool flag = true;
      for(int j = 3; j <= sqrt(i); j += 2){
	if(i % j == 0){
	  flag = false;
	}
      }
      if(flag)
	ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	long long int N,count[1000000];
		count[1] = 1;
	for(int x=2;x<=1000000;x++){
		int flag = 0;
		for(int y=2;y<x;y++){
			if((x%y)==0)	flag = 1;
		}
		if(flag == 0)	count[i] = count[i-1]+1;
	}
	while(cin >> N){
		cout << count[N] << endl;
	}
	return 0;
}

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

int main(void) {
    int n;
    while(cin >> n) {
        int a[n];
        for(int i = 0; i <= n; i++) {
            a[i] = 1;
        }
        for(int i = 2; i <= sqrt(n); i++) {
            if(a[i]) {
                for(int j = 2; i * j <= n; j++) {
                    a[i * j] = 0;
                }
            }
        }
        int cnt = 0;
        for(int i = 2; i <= n; i++)
            if (a[i]) cnt++;
        cout << cnt << endl;
    }
}

C++: #include<iostream>
#include<stdlib.h>
main(){
	int i,j,n;//,p[1000000];
	std::cin>>n;

	int *p=(int *)malloc(8000000);
	for(i=2;i<=n;i++)
		p[i]=1;
	for(i=2;i<n;i++)
		for(j=2;i*j<=n;j++)
			p[i*j]=0;
	j=0;
	for(i=2;i<=n;i++)
		j+=p[i];
	std::cout<<j<<std::endl;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n, cnt;
	bool prime[1000000] = {false};
	prime[1] = true; //1???????????\	
	
	while(cin >> n){	
		// ??¨??????????????????????????????
		for(int j = 2; j*j <= n; j++){
			if(prime[j] == false){
				for(int k = j; k*j <= n; k++){
					prime[j*k] =true;
				}
			}
		}
		cnt = 0;
		for(int i = 1; i <= n; i++){
			if(prime[i] == false) cnt++;
		}
		
		cout << cnt << endl;
	}
}

C++: #include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    while(cin >> n) {
        int ans = 1;
        
        for(int i = 3; i <= n; i+=2) {
            bool isPrime = true;
            for(int j = 3; (j * j) <= i; j+=2) {
                if(i % j == 0) {
                    isPrime = false;
                    break;
                }
            }
            if(isPrime) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

C++: 
#include <iostream>
#include <stdlib.h>
using namespace std;
#define thefor(i,end) for (i=0;i<end;i++)
int main()
{    
	int n,con,a,i,j;
	while(cin>>n)
	{
		con=1;
		for (i=3;i<=n;i++)
		{
			for (j=2;j<i;j++)
			{
				if (i%j==0)
				{
					break;
				}
			}
			if (j==i)
			{
				con++;
			}
		}
		cout<<con<<endl;
	}
	
}