Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [100]int
	var inputCount, primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		resultArr[inputCount] = primeCount
		if inputCount == 30 {
			break
		}
		primeCount = 0
		inputCount++
	}
	for _, v := range resultArr {
		fmt.Printf("%d\n", v)
	}
}

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
}

C++: #include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
bool primenum(int a)
{
    int i;
    int s;
    s=(int)sqrt(a)+1;
    if(a==2) return true;
    for(i=2;i<=s;i++)
    {
        if(a%i==0)
        {
            break;
        }
    }
    if(i==s+1)
    {
        return true;
    }
    else
        return false;
}
int main()  
{  
    int n;
    while(cin>>n)
    {

    
        int counter=0;
        for(int j=2;j<=n;j++)
        {
            if(primenum(j))
            {
                counter++;
            }
            
        }
        cout<<counter<<endl;
    }
    //system("pause");
    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 = 0; i * (j + 2) <= n; j++) {
                    a[i * (j + 2)] = 0;
                }
            }
        }
        int cnt = 0;
        for(int i = 2; i <= n; i++)
            if (a[i]) cnt++;
        cout << cnt << endl;
    }
}

C++: #include <stdio.h>

int main(void) {

  int n;
  int num;
  int i,p,k,count;
  int flag[1000000];

  while(scanf("%d",&n)!=EOF) {

    num=(n-3)/2;

    for(i=0;i<=num;i++) {
      flag[i]=1;
    }

    for(i=0;i<=num;i++) {
      if(flag[i]==1) {
	p=i+i+3;
	printf("%d\n",p);

	for(k=i+p;k<=num;k+=p) {
	  flag[k]=0;
	}
      }
    }
  }

  return 0;
}

C++: #include <iostream>
//#include <stdio.h>
using namespace std;
int main() {
  
  //char str[10];
  long n,i=1,count=0;
  //long exp=1,result[10]={0,0,0,0,0,0,0,0,0,0};

  cin >> n;

  while(i<=n) {
    if(n%i==0) count++;
    i++;
  }

  printf("%ld",count);
  return 0;
}

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

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

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

bool check(int in){
	for (int i = 3; i<=sqrt(in); i+=2){
		if (i != 5 && i % 5 == 0)	continue;
		if (in % i == 0)
			return false;
	}
	return true;
}

int PrimeNumber(int in, int start){
	int count = 0;
	if (in >= 2 && start==3)	count++;
	for (int i = start; i <=in; i+=2){
		if (check(i))	count++;
	}

	return count;
}

int main(){
	int in;
	int count250000 = PrimeNumber(250000, 3);
	int count500000 = count250000 + PrimeNumber(500000, 250001);
	int count750000 = count500000 + PrimeNumber(750000, 500001);

	while (cin >> in, !cin.eof()){
		if (in <= 250000)
			cout << PrimeNumber(in, 3) << endl;
		else if (in <= 500000)
			cout << count250000 + PrimeNumber(in, 250001) << endl;
		else if (in <= 750000)
			cout << count500000 + PrimeNumber(in, 500001) << endl;
		else
			cout << count750000 + PrimeNumber(in, 750001) << endl;
	}
}

C++: #include <iostream>
using namespace std;
typedef long long int LL;
#define MOD 1000000007

LL pow(LL m, LL n)
{
	LL res = 1,x = 1,a = m;
	while (x <= n) {
		if ((x & n) > 0) {
			res *= a;
			res %= MOD;
		}
		a *= a;
		a %= MOD;
		x <<= 1;
	}
	res %= MOD;
	return res;
}

int main()
{
	LL m, n;
	cin >> m >> n;
	cout << pow(m,n) << endl;
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);


int main() {
  bool prime[1000005];
  int primenum[1000005];
  for(int i=0;i<1000005;++i) prime[i] = true;
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<1000005;++i){
    if(prime[i]==false) continue;
    for(int j=2;i*j<1000005;++j){
      prime[i*j] = false;
    }
  }
  primenum[0] = 0;
  primenum[1] = 0;
  for(int i=2;i<1000005;++i){
    if(prime[i]){
      primenum[i] = primenum[i-1] + 1;
    }
    else{
      primenum[i] = primenum[i-1];
    }
  }
  int N;
  while(cin>>N){
    cout<<primenum[N]<<endl;
  }
}

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

int main() {
    while(cin) {
        int n;
        cin >> n;
        
        int count = 0;
        for(int i=1; i<=n; i++) {
            int k = 0;
            for(int j=1; j<=i; j++) {
                if(i%j == 0) k++;
            }
            if(k == 2) {
                count ++;
            }
        }
        cout << count << endl;
    }
    return 0;
}

C++: #include <stdio.h>

#define MAX (1000000)

bool primeTbl[MAX];

int main() {
	
	primeTbl[0] = primeTbl[1] = true;
	for(int i=2; i<MAX; i++) {
		if(!primeTbl[i])
			for(int j=i*2; j<MAX; j+=i)
				primeTbl[j] = true;
	}

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

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

bool IsPrimeNumber(int number) {
	if (number < 2) return false;
	if (number == 2) return true;
	if (number % 2 == 0) return false;
	int max = (int)std::sqrt(number);
	for (int i=3; i<=max; i+=2)
		if (number % i == 0)
			return false;
	return true;
}

int main() {
	int N[1000000] = {0};
	for (int i=1; i<=999999; i++) {
		if (IsPrimeNumber(i)) {
			N[i] = N[i-1] + 1;
		} else {
			N[i] = N[i-1];
		}
	}
	int n;
	while (std::cin >> n) {
		std::cout << N[n] << std::endl;
	}
	return 0;
}

C++: #include<iostream>
#define N 999999
#define FOR(i,a,b) for( int i = ( a ); i < ( b ); i++ )
#define WHILE(n) while( std::cin >> n )
int p[(N+1)/2];int m[N+1];int mk();using namespace std;int main(){int n;p[0]=2;m[1]=0;m[2]=1;mk();WHILE(n){cout<<m[n]<<'\n';}return 0;}int mk(){int i,j,e=1;FOR(i,3,N){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}}