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;

int main(){

  int m,n;

  while(cin>>m>>n, m || n){
	
	int count = 0;
	
	for(int i=m;i<=n;++i){

	  int result = i;
	  
	  while(1){

		if(result%2==0)
		  result = result/2;
		else if(result%3==0)
		  result = result/3;
		else if(result%5==0)
		  result = result/5;
		else
		  break;
	  }
	  
	  if(result == 1)
		count++;
	  
	}

	cout<<count<<endl;
	
  }
  
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    bool hamming[1000001]={};
    for(int i=1;i<1000001;i*=5){
        for(int j=i;j<1000001;j*=3){
            for(int k=j;k<1000001;k*=2)hamming[k]=1;
        }
    }
    int m;
    while(cin>>m,m){
        int n,co=0;
        cin>>n;
        for(int i=m;i<=n;i++)if(hamming[i])co++;
        cout<<co<<endl;
    }
}

C++: #include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

ll solve(const ll m, const ll n) {
    queue<ll> q2;
    queue<ll> q3;
    queue<ll> q5;

    // 1 is always included.
    ll count = 0;
    q2.push(1);

    while (1) {
        ll cand;
        if (q2.size() > 0) cand = q2.front();
        if (q3.size() > 0) cand = min(cand, q3.front());
        if (q5.size() > 0) cand = min(cand, q5.front());

        if (q2.front() == cand) {
            q2.pop();
            q2.push(2 * cand);
            q3.push(3 * cand);
            q5.push(5 * cand);
        } else if (q3.front() == cand) {
            q3.pop();
            q3.push(3 * cand);
            q5.push(5 * cand);
        } else {
            q5.pop();
            q5.push(5 * cand);
        }

        if (m <= cand && cand <= n) {
            count++;
        }
        if (cand > n) {
            break;
        }
    }

    return count;
}

int main(void) {
    ll m, n;

    while (1) {
        cin >> m;
        if (m == 0) return 0;
        cin >> n;

        cout << solve(m, n) << endl;
    }
    
    return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
  int n, m, a[1000000], p = 0, c, t;

  for(int i = 1; i <= 1000000; i++){
    t = i;
    while(t%5 == 0){
      t /= 5;
    }
    while(t%3 == 0){
      t /= 3;
    }
    while(t%2 == 0){
      t /= 2;
    }
    if(t == 1){
      a[p++] = i;
    }
  }

  while(1){
    cin >> m;
    if(m == 0){
      break;
    }
    cin >> n;
    c = 0;
    for(int i = 0; i < p && a[i] <= n; i++){
      if(m <= a[i]){
	c++;
      }
    }
    cout << c << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
vector<bool>ha(1000010,false);
void hami(vector<bool>& ha,int n){
  if(n*2<=1000000&&!ha[2*n]){ha[2*n]=true;hami(ha,n*2);}
  if(n*3<=1000000&&!ha[3*n]){ha[3*n]=true;hami(ha,n*3);}
  if(n*5<=1000000&&!ha[5*n]){ha[5*n]=true;hami(ha,n*5);}
}
int main(){
  hami(ha,1);
  ha[1]=true;

  int n,m;
  while(cin>>n,n){
    cin>>m;
    int co=0;
    loop(i,n,m+1)if(ha[i])co++;
    cout<<co<<endl;
  }
}

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

int main(void){
	int m,n,ans;
	while(cin>>m,m){
		cin>>n;
		ans = 0;
		for(int i = 1; i <= n ; i *= 5)
		for(int j = i; j <= n ; j *= 3)
		for(int k = j; k <= n ; k *= 2){
			if(k>=m)
				ans ++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int n,m;
    while(cin >> n,n){
        cin >> m;
        int ans = 0;
        for(int i = n; i <= m; i++){
            int t = i;
            while(t % 2 == 0)t /= 2;
            while(t % 3 == 0)t /= 3;
            while(t % 5 == 0)t /= 5;
            if(t == 1)ans++;
        }
        cout << ans << endl;
    }
}

C++: #include <bits/stdc++.h>

using namespace std;

#define MAX 1000000
 
int main()
{
    int m, n;
     
    while (cin >> m, m) {
        cin >> n;
        int cnt = 0;
        for (int i = m; i <= n; i++) {
            int tmp = i;
            while (!(tmp%2) || !(tmp%3) || !(tmp%5)) {
                if (!(tmp%2)) tmp /= 2;
                else if (!(tmp%3)) tmp /= 3;
                else if (!(tmp%5)) tmp /= 5;
            }
            if (tmp == 1) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

C++: #include<stdio.h>

int judge(int,int);

int memo[1000001];

int main(void){
  int n,m,i,count;

  for(i=0;i<1000001;i++)
    memo[i]=-1;
  
  memo[0]=1;
  memo[1]=0;

  while(scanf("%d",&n),n){
      scanf("%d",&m);

    count=0;
    for(i=n;i<=m;i++){
      if(judge(i,1)==0){
	memo[i]=0;
	count++;
      }
    }
    printf("%d\n",count);
  }
  return 0;
}

int judge(int x,int fg){

  if(x%2==0)judge(x/2,2);
  else if(x%3==0)judge(x/3,3);
  else if(x%5==0)judge(x/5,5);

  if(memo[x]==0){
    memo[x*fg]=0;
    return 0;
  }
  return memo[x]=1;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;


int flag[MAXN];
int num[MAXN];
int main() {

    int n, m;

    for(int i=1; i<MAXN; i*=2) {
        for(int j=i; j<MAXN; j*=3) {
            for(int k=j; k<MAXN; k*=5) {
                flag[k] = 1;
            }
        }
    }

    for(int i=1; i<MAXN; ++i) {
        num[i]=num[i-1]+flag[i];
    }

    while(cin >> m >> n, m) { // if (m>0)
        cout << num[n]-num[m-1] << endl;
    }
}

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

int isHammingNumber(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>
using namespace std;

int main(){
  int n,m,k,ans;
  bool h[1000001];
  bool f;

  for(int i=0;i<=1000000;i++)h[i] = false;
  h[1] = true;

  k = 2;
  f = true;
  while(f){
    f = false;
    for(int i=1;i<=1000000/k;i++){
      if(h[i]){
	if(!h[k*i]){
	  f = true;
	  h[k*i] = true;
	}
      }
    }
    k *= 2;
  }

  k = 3;
  f = true;
  while(f){
    f = false;
    for(int i=1;i<=1000000/k;i++){
      if(h[i]){
	if(!h[k*i]){
	  f = true;
	  h[k*i] = true;
	}
      }
    }
    k *= 3;
  }

  k = 5;
  f = true;
  while(f){
    f = false;
    for(int i=1;i<=1000000/k;i++){
      if(h[i]){
	if(!h[k*i]){
	  f = true;
	  h[k*i] = true;
	}
      }
    }
    k *= 5;
  }

  while(1){
    cin >> n;
    if(!n)break;
    cin >> m;

    ans = 0;
    for(int i=n;i<=m;i++){
      if(h[i])ans++;
    }
    cout << ans << endl;
  }
}