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++: #include<iostream>
using namespace std;
int main(){
	bool a[1000000];
	for(int abc=2;abc<=999999;abc++){
		a[abc]=true;
	}
	for(int abc=2;abc<=999999;abc++){
		if(a[abc]==true){
			for(int ab=abc*2;ab<=999999;ab+=abc){
				a[ab]=false;
			}
		}
	}
	int ad;
	while(cin>>ad){
		int ansa=0;
		for(int abc=2;abc<=ad;abc++){
			if(a[abc]==true){
				ansa++;
			}
		}
		cout<<ansa<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;
int main()
{
    long long n;
    long long prime = 0;

    cin >> n;
    
    for(int x=1; x<=n; x++)
    {
            int counter = 0;
            for(int y=1; y<=x; y++)
            {
                    if(x%y==0)
                    counter++;
            }
            
            if(counter==2)
            {
                    cout << x << endl;
                    prime++;
            }
    }
    
    cout << prime << endl;
    
return 0;
}

C++: #include <cstdio>
 
int main(){
  bool cmp[1000000]={true};
  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;scanf("%d", &n);n++){
  	printf("%d\n", npr[n]);
  }
  return 0;
}

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

int main(){

  int n;

  while(cin>>n){

	int cnt=0;
	
	if(n <= 1){
	  cout<<0<<endl;
	  continue;
	}

	else
	  cnt++;
	
	for(int i=3;i<=n;i+=2){
	  int f = true;
	  for(int j=2;j<i;j++){
		if(i%j==0){
		  f = false;
		  break;
		}
	  }
	  if(f == true)
		cnt++;
	}

	cout<<cnt<<endl;
	
  }

  return 0;
  
}

C++: #include <iostream>

bool Check(int);

int main(void)
{
    int input;
    int count;
    while(std::cin >> input){
        count = 0;
        for(int j=2;j <= input;++j){
            if(Check(j)){
                ++count;
            }
        }
        std::cout << count << std::endl;
    }
    return 0;
}
bool Check(int value)
{
    bool result = true;
    for(int i=value / 2;i >= 2;--i){
        if(value % i == 0){
            result = false;
            break;
        }
    }
    return result;
}

C++: //
//  main.cpp
//  CppTest
//
//  Created by Ryu on 2017/02/08.
//  Copyright ?? 2017??´ Ryu. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    long in[30];
    long out[30];
    int n = 0;
    long max = 0;
    while(cin >> in[n]){
        if(max < in[n]){
            max = in[n];
        }
        n++;
    }
    //printf("%d", n);
    
    long p[100000];
    //int length = sizeof(p) / sizeof(*p);
    int m = 0;
    //printf("length: %d", length);
    for (int i = 2; i <= max; i++) {
        bool prime = true;
        for(int j = 0; j < m; j++){
            if (i % p[j] == 0) {
                prime = false;
            }
        }
        if (prime) {
            p[m] = i;
            //printf("%ld\n", p[m]);
            m++;
        }
    }
    
    
    for (int i = 0; i < n; i++) {
        int s = 0;
        while (in[i] >= p[s] && p[s] != 0) {
            //printf("in: %ld, p: %ld\n", in[i], p[s]);
            s++;
        }
        out[i] = s;
        printf("%ld\n", out[i]);
    }
    
    return 0;
}

C++: #include <iostream>                                                                                                     
#include <vector>                                                                                                       
                                                                                                                        
using namespace std;                                                                                                    
                                                                                                                        
int main() {                                                                                                            
  int n;                                                                                                                
  int count;                                                                                                            
  while (cin >> n) {                                                                                                    
    if (n == 1) { cout << 0 << endl; continue; }                                                                        
    vector<int> prime_numbers; // 素数リスト                                                                            
    count = 1;                                                                                                          
    for (int i = 2; i <= n; i++) {                                                                                      
      bool prime = true;                                                                                                
      for (vector<int>::iterator itr = prime_numbers.begin(); itr != prime_numbers.end(); itr++) {                      
        if (i % *itr == 0) {                                                                                            
          prime = false;                                                                                                
          break;                                                                                                        
        }                                                                                                               
      }                                                                                                                 
      if (prime) {                                                                                                      
        prime_numbers.push_back(i);                                                                                     
        count += 1;                                                                                                     
      }                                                                                                                 
    }                                                                                                                   
    cout << count << endl;                                                                                              
  }                                                                                                                     
  return 0;                                                                                                             
}

C++: #include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
int vis[1000000];
int n;int sum;
void pre()
{
    memset(vis, 0, sizeof(vis));
for(int i = 2; i <= 999999; i++)
	for(int j = i*2; j <= 999999; j += i)
		vis[j] = 1;
}
int main()
{
    pre();
    while(scanf("%d",&n)!=EOF)
    {
        sum=0;
        for(int i=2;i<=n;i++)
        {
            if(!vis[i])
                sum++;
        }
        printf("%d\n",sum);
    }
    return 0;
}