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)
	}
}

Python: twos =   [2 ** i for i in range(21) if 2 ** i <= 1000000]
threes = [3 ** i for i in range(21) if 2 ** i <= 1000000]
fives =  [5 ** i for i in range(21) if 2 ** i <= 1000000]
muls = [x * y * z for x in twos for y in threes for z in fives]
muls.sort()
def under(n):
  cnt = 0
  for i in muls:
    if i <= n:
      cnt += 1
    else:
      break
  return cnt

while True:
  s = input()
  if s == "0":
    break

  m, n = map(int, s.split())
  print(under(n) - under(m - 1))

Python: # AOJ 0162 Hamming Numbers
# Python3 2018.6.23 bal4u

MAX = 1000000

t = [0]*(MAX+5)

a5 = 1
for i in range(9):
	a3 = 1
	for j in range(13):
		a35 = a5*a3
		if a35 > MAX: break
		a2 = 1
		for k in range(20):
			if a35*a2 > MAX: break
			t[a35*a2] = 1
			a2 <<= 1
		a3 *= 3
	a5 *= 5
while 1:
	a = input()
	if a == '0': break
	m, n = map(int, a.split())
	print(sum(t[m:n+1]))

Python: while 1:
    n=list(map(int,input().split()))
    if n[0]==0:break
    a=0
    for i in range(n[0],n[1]+1):
        b=i
        while b%2==0: b/=2
        while b%3==0: b/=3
        while b%5==0: b/=5
        if b==1:a+=1
    print(a)

Python: def hammingp(n):
    while n % 2==0:
        n /= 2
    while n % 3==0:
        n /= 3
    while n % 5==0:
        n /= 5
    return(n==1)

while True:
    s = list(map(int,input().strip().split()))
    if len(s)==1:
        break
    m,n = s

    c=0
    for i in range(m,n+1):
        if hammingp(i):
            c += 1
    print(c)

Python: while True:
    n = input()
    if n == '0': break
    m, n = map(int, n.split())
    cnt = 0
    for i in range(m, n+1):
        num = i
        while num % 5 == 0:
            num /= 5
        while num % 3 == 0:
            num /= 3
        while num % 2 == 0:
            num /= 2
        if num == 1:
            cnt += 1
    print(cnt)

Python: MAX = 1000000

hamming_list = [False] * (MAX + 1)

hamming_list[0] = False
hamming_list[1] = True

for index in range(2, MAX + 1):

    if index % 2 == 0:
        if hamming_list[index // 2]:
            hamming_list[index] = True
    elif index % 3 == 0:
        if hamming_list[index // 3]:
            hamming_list[index] = True
    elif index % 5 == 0:
        if hamming_list[index // 5]:
            hamming_list[index] = True

while True:

    input_data = input()

    if input_data == "0":
        break

    start, end = [int(item) for item in input_data.split(" ")]

    count = sum(hamming_list[start:end + 1])
    print(count)

Python: import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


SIZE_2 = 20
SIZE_3 = 13
SIZE_5 = 9
NUM = 1000001

POW_2 = [1]*SIZE_2
for i in range(1,SIZE_2):
    POW_2[i] = POW_2[i-1]*2

POW_3 = [1]*SIZE_3
for i in range(1,SIZE_3):
    POW_3[i] = POW_3[i-1]*3

POW_5 = [1]*SIZE_5
for i in range(1,SIZE_5):
    POW_5[i] = POW_5[i-1]*5

table = [0]*(NUM)

for i in range(SIZE_2):
    for k in range(SIZE_3):
        if POW_2[i]*POW_3[k] >= NUM:
            break
        for p in range(SIZE_5):
            if POW_2[i]*POW_3[k]*POW_5[p] >= NUM:
                break
            table[POW_2[i]*POW_3[k]*POW_5[p]] = 1

for i in range(1,NUM):
    table[i] += table[i-1]

while True:
    tmp_str = input()
    if len(tmp_str) == 1 and tmp_str[0] == "0":
        break
    left,right = map(int,tmp_str.split())
    print("%d"%(table[right]-table[left-1]))

Python: while True:
    A = list(map(int, input().split()))
    if A[0] == 0:
        break
 
    n, m = A[0], A[1]
    ans = 0
    for i in range(n, m+1):
        b = i
        while b % 5 == 0:
            b //= 5
        while b % 3 == 0:
            b //= 3
        while b % 2 == 0:
            b //= 2
        if b == 1:
            ans += 1
    print(ans)

Python: # Aizu Problem 00161: Sport Meet
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


N = 1000000
hamming = [False] * (N + 1)
ans = [0] * (N + 1)
hamming[1] = True
ans[1] = 1
for k in range(2, N + 1):
    if (k % 2 == 0 and hamming[k//2]) or \
       (k % 3 == 0 and hamming[k//3]) or (k % 5 == 0 and hamming[k//5]):
        hamming[k] = True
    ans[k] = ans[k-1]
    if hamming[k]:
        ans[k] += 1


while True:
    s = [int(_) for _ in input().split()]
    if len(s) == 1 and s[0] == 0:
        break
    m, n = s[:]
    print(ans[n] - ans[m-1])

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0162

"""
import sys
from sys import stdin
from bisect import bisect_right, bisect_left
input = stdin.readline


def main(args):
    hammings = []

    temp = set()
    for i in range(21):
        for j in range(14):
            for k in range(9):
                ans = 2**i * 3**j * 5**k
                temp.add(ans)

    hammings = list(temp)
    hammings.sort()

    while True:
        try:
            m, n = map(int, input().split(' '))
        except ValueError:
            break

        s = bisect_left(hammings, m)
        t = bisect_right(hammings, n)

        print(t - s)


if __name__ == '__main__':
    main(sys.argv[1:])

Python: MAX = 1000000

hamming_list = [False] * (MAX + 1)

hamming_list[0] = False
hamming_list[1] = True

for index in range(2, MAX + 1):

    if index / 2 % 1 == 0:
        if hamming_list[index // 2]:
            hamming_list[index] = True
    elif index / 3 % 1 == 0:
        if hamming_list[index // 3]:
            hamming_list[index] = True
    elif index / 5 % 1 == 0:
        if hamming_list[index // 5]:
            hamming_list[index] = True

while True:

    input_data = input()

    if input_data == "0":
        break

    start, end = [int(item) for item in input_data.split(" ")]

    count = sum(hamming_list[start:end + 1])
    print(count)

Python: while 1:
    datas = list(map(int, input().split()))
    if datas[0] == 0:
        break

    n, m = datas[0], datas[1]
    cnt = 0
    for i in range(n, m+1):
        b = i
        while b % 5 == 0:
            b //= 5
        while b % 3 == 0:
            b //= 3
        while b % 2 == 0:
            b //= 2
        if b == 1:
            cnt += 1
    print(cnt)

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0162

"""
import sys
from sys import stdin
from bisect import bisect_right, bisect_left
from math import ceil, log
input = stdin.readline


def main(args):
    hammings = []

    temp = set()
    for i in range(ceil(log(1e6, 2)) + 1):
        for j in range(ceil(log(1e6, 3)) + 1):
            for k in range(ceil(log(1e6, 5)) + 1):
                ans = 2**i * 3**j * 5**k
                temp.add(ans)

    hammings = list(temp)
    hammings.sort()

    while True:
        try:
            m, n = map(int, input().split(' '))
        except ValueError:
            break

        s = bisect_left(hammings, m)
        t = bisect_right(hammings, n)

        print(t - s)


if __name__ == '__main__':
    main(sys.argv[1:])