Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)
const (
	MAX = 1000000
)
func main() {
	a := make([]int, MAX+1)
	a[1] = 1
	for i := 2; i <= MAX; i *= 2 {
		a[i]++
	}
	for i := 1; i <= MAX; i++ {
		if a[i] != 0 {
			for j := i*3; j <= MAX; j *= 3 {
				if a[j] == 0 {
					a[j]++
				}
			}
		}
	}
	for i := 1; i <= MAX; i++ {
		if a[i] != 0 {
			for j := i*5; j <= MAX; j *= 3 {
				if a[j] == 0 {
					a[j]++
				}
			}
		}
	}
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		m, _ := strconv.Atoi(buf[0])
		if m == 0 {
			break
		}
		n, _ := strconv.Atoi(buf[1])
		cnt := 0
		for i := m; i <= n; i++ {
			if a[i] != 0 {
				cnt++
			}
		}
		fmt.Println(cnt)
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int n, m, ans;

bool is_Hamming( int d ) {
	if ( d == 1 ) {
		return true;
	}
	if ( d % 2 == 0 ) {
		return is_Hamming( d / 2 );
	}
	if ( d % 3 == 0 ) {
		return is_Hamming( d / 3 );
	}
	if ( d % 5 == 0 ) {
		return is_Hamming( d / 5 );
	}
	return false;
}

int main() {
	while ( ~scanf( "%d", &n ) && n ) {
		scanf( "%d", &m );
		ans = 0;
		for ( int i = n; i <= m; i++ ) {
			ans += is_Hamming( i );
		}
		printf( "%d\n", ans );
	}
	return 0;
}

C++: //2013/11/25(Mon)

#include <iostream>
using namespace std;

int main()
{
	int m,n;

	bool ham[1000001];
    for(int i=0; i<=1000000; i++)
        ham[i] = false;
 
    for(int i=1; i<=1000000; i*=2)
        for(int j=i; j<=1000000; j*=3)
            for(int k=j; k<=1000000; k*=5)
                ham[k] = true;
 
    while(true){
		  int cnt = 0;

			cin >> m;
        if(m==0)
            break;
			cin >> n;
 
        for(int i=m; i<=n; i++)
            if(ham[i] == true)
                cnt++;
 
        cout << cnt << endl;
    }
 
    return 0;
}

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

int main(){
	int hamming[MAX];
	for(int i=0;i<MAX;i++){
		hamming[i]=0;
	}
	long int tmp =0;
	for(int i=0;tmp<MAX;i++){
		for(int j=0;tmp<MAX;j++){
			for(int k=0;tmp<MAX;k++){
				tmp =pow(2,i)*pow(3,j)*pow(5,k);
				if(tmp<MAX){
					hamming[tmp]=1;
				}
			}
			tmp =pow(2,i)*pow(3,j+1)*pow(5,0);
		}
		tmp =pow(2,i+1)*pow(3,0)*pow(5,0);
	}
	
	
	int a,b;
	while(cin>>a,a!=0){
		cin>>b;
		int ans=0;
		for(int i=a;i<b+1;i++){
			ans+=hamming[i];
		}
		cout<<ans<<endl;
	}
	
}

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

int HammingNumber(int n){
	int p=n;
	while(p%2 == 0)p/=2;
	while(p%3 == 0)p/=3;
	while(p%5 == 0)p/=5;
	return p==1;
}

int main() {
	
	int m,n;
	int count;
	
	while(count=0,cin>>m>>n,m){
		for(int i=m;i<=n;++i)if(HammingNumber(i))++count;
		cout << count << endl;
	}
	return 0;	
}

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

using namespace std;

int haming(int x){

  while(1){

    int flag = 0;

    if( x % 5 == 0 ){
      x /= 5;
      flag++;
    }
    if( x % 3 == 0 ){
      x /= 3;
      flag++;
    }
    if( x % 2 == 0 ){
      x /= 2;
      flag++;
    }

    if( x != 1 && flag == 0 ) return 0;
    if( x == 1 && flag > 0 ) return 1;

  }
}

int main(void){

  int m,n;

  while(1){

    cin >> m;
    if( m == 0 ) break;
    cin >> n;

    int h = 0;
    for( int i = m ; i <= n ; i++ ){
      if( i == 1 ) h++;
      else h +=  haming(i);
    }
    cout << h << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string.h>

using namespace std;
int Memo[1000001];
bool IsHamming[1000001];

void Calc()
{
	memset(IsHamming, 0, sizeof(bool) * 1000001);
	for(int i = 1; i < 1000001; ++i)
	{
		int temp = i;
		while(temp % 2 == 0)
		{
			temp /= 2;
		}
		while(temp % 3 == 0)
		{
			temp /= 3;
		}
		while(temp % 5 == 0)
		{
			temp /= 5;
		}
		if(temp == 1)
		{
			IsHamming[i] = true;
		}
	}
	int count = 0;
	for(int i = 1; i < 1000001; ++i)
	{
		if(IsHamming[i])
		{
			count++;
		}
		Memo[i] = count;
	}
}

void solve()
{
	Calc();
	int	m, n;
	while(cin >> m)
	{
		if(!m)
		{
			break;
		}
		cin >> n;
		if(IsHamming[m])
		{
			cout <<	Memo[n] - Memo[m] + 1 << endl;
		} 
		else
		{
			cout << Memo[n] - Memo[m] << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<iostream>
using namespace std;
/*
bool sw[1000001];
int i;
 
void sws(int k){
        if(k==1){
                sw[i]=true;
                return;
        }
        if(k%2==0) sws(k/2);
        else if(k%3==0) sws(k/3);
        else if(k%5==0) sws(k/5);
        return;
}
*/
// korenisuru
int dp[1000001];
int f(int n){
        if(~dp[n]) return dp[n];
        int ans = 0;
        if(n%2==0) ans |= f(n/2);
        if(n%3==0) ans |= f(n/3);
        if(n%5==0) ans |= f(n/5);
        return dp[n] = ans;
}
 
int main() {
        int k,m,n;
        for(int i = 0 ; i <= 1000000 ; i++) dp[i] = -1;
        dp[1] = 1;
        /*
        for(int j=0;j<1000001;j++) sw[j]=false;
        for(i=1;i<1000001;i++) sws(i);
        while(cin >> m,m){
                int ans=0;
                cin >> n;
                for(int j=m;j<=n;j++) if(sw[j]==true) ans++;
                cout << ans << endl;
        }*/
        while(cin >> m && m){
                cin >> n;
                int ans = 0;
                for(int i = m ; i <= n ; i++) ans += f(i);
                cout << ans << endl;
        }
        return 0;
}

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

using namespace std;

int main(){

	int m,n,elem[3] = {2,3,5},tmp;
	int* table = new int[1000001];
	table[0] = 0;
	table[1] = 1;

	for(int i = 2; i <= 1000000; i++){
		tmp = i;
		for(int k = 0; k < 3; k++){
			while(tmp%elem[k] == 0){
				tmp /= elem[k];
			}
		}
		if(tmp == 1){
			table[i] = table[i-1]+1;
		}else{
			table[i] = table[i-1];
		}
	}


	while(true){
		scanf("%d %d",&m,&n);
		if(m == 0)break;

		printf("%d\n",table[n]-table[m-1]);
	}

    return 0;
}