鱼C论坛

 找回密码
 立即注册
查看: 2116|回复: 1

题目204:广义汉明数

[复制链接]
发表于 2016-11-22 18:58:49 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

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

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-8-15 10:41:20 | 显示全部楼层
  1. def hamming(n):
  2.         base = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
  3.         hamm = [1]
  4.         for i in base:
  5.                 for j in hamm:
  6.                         if i*j<=n:
  7.                                 hamm.append(i*j)
  8.         return len(hamm)
  9. print(hamming(10**9))
复制代码

2944730
[Finished in 2.1s]
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-1 12:51

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表