【问题标题】:How to approximate the sum of number of divisors from 1 to n?如何近似从 1 到 n 的除数之和?
【发布时间】:2017-05-02 12:03:51
【问题描述】:

问题

我想解决这个问题:

让除数的个数=d(n)(比如d(6)=4,因为数字6有4个除数,{1,2,3,6}),我要计算d(1)+ d(2)+d(3)+...+d(n)。

但是我无法计算像 10^20 或 10^30 这样的大 n (我认为如果 n 与 10^30 一样大,几秒钟内计算的算法不存在),所以我决定找到算法大约计算

我目前的解决方案

我发现答案在 n log n 附近(log 的底数是 e=2.71828...)

但在 n = 10^17 的情况下,误差约为 0.4%。

这有点准确,但我认为有更准确的算法。

有没有更准确的算法?

【问题讨论】:

  • 算法当然存在
  • @JoshLee 什么意思?你知道在几秒钟内确定性地求解 d(1)+d(2)+...+d(n) 的算法吗?
  • 对 n 的大小、运行时间或存储要求没有任何限制,“n 的除数之和”的算法对于小 n 和大 n 是相同的。例如,说天真的算法需要指数时间,可以澄清你的意思。
  • @JoshLee Little 编辑了我的问题。 n 约为 10^30
  • oeis.org/A000203 的 Haskell 代码对我来说似乎很快。

标签: algorithm approximation number-theory


【解决方案1】:

Encyclopedia of Mathematics 表示估算值

n log n + (2γ - 1)n + O(√n)

致狄利克雷 (1849)。 γ 是Euler–Mascheroni constant。你可以去掉 O(√n) 误差项。

【讨论】:

    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-14
      • 2022-11-17
      • 2018-05-04
      • 1970-01-01
      • 1970-01-01
      • 2021-03-19
      • 1970-01-01
      相关资源
      最近更新 更多