欧拉计划 发表于 2016-11-22 18:58:49

题目204:广义汉明数

Generalised Hamming Numbers

A 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 的汉明数有多少个?

jerryxjr1220 发表于 2017-8-15 10:41:20

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]
查看完整版本: 题目204:广义汉明数