题目204:广义汉明数
Generalised Hamming NumbersA Hamming number is a positive number which has no prime factor larger than 5.
So the first few Hamming numbers are 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15.
There are 1105 Hamming numbers not exceeding 108.
We will call a positive number a generalised Hamming number of type n, if it has no prime factor larger than n.
Hence the Hamming numbers are the generalised Hamming numbers of type 5.
How many generalised Hamming numbers of type 100 are there which don't exceed 109?
题目:
汉明数是没有大于 5 的质因子的正整数。
所以,前几个汉明数分别是 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15。
在比 108 小的数字中,有 1105 个汉明数。
我们把没有大于 n 的质因子的数叫做 n 类型的广义汉明数。
所以,标准的汉明数是类型为 5 的汉明数。
请问在 109 以内(包含),类型 100 的汉明数有多少个?
def hamming(n):
base =
hamm =
for i in base:
for j in hamm:
if i*j<=n:
hamm.append(i*j)
return len(hamm)
print(hamming(10**9))
2944730
页:
[1]