寻找具有给定因子数的最小数的算法

标签 algorithm numbers number-theory

什么是任何人能想到的最有效的算法,给定一个自然数 n,返回 n 为正的最小自然数 x除数(包括 1 和 x)?例如,给定 4,算法应得出 6(除数:1,2,3,6);即 6 是具有 4 个不同因子的最小数字。类似地,给定 6,算法的结果应该是 12(除数:1,2,3,4,6,12);即 12 是具有 6 个不同因子的最小数字

就现实世界的性能而言,我正在寻找一种可扩展的算法,它可以在一台可以做 107 的机器上在 2 秒内给出 1020 数量级的答案 每秒计算。

最佳答案

http://www.primepuzzles.net/problems/prob_019.htm

b) Jud McCranie, T.W.A. Baumann & Enoch Haga sent basically the same procedure to find N(d) for a given d:

  1. Factorize d as a product of his prime divisors: d = p1a1 * p2a2 *p3a3 *...
  2. convert this factorization in another arithmetically equivalent factorization, composed of non-powered monotonically decreasing and not necesarilly prime factors... (uf!...) d = p1a1 * p2a2 *p3a3 *... = b1 * b2 * b3... such that b1 ≥ b2 ≥ b3...
    You must realize that for every given d, there are several arithmetically equivalent factorizations that can be done: by example:
    if d = 16 = 24 then there are 5 equivalent factorizations: d = 2*2*2*2 = 4*2*2 = 4*4 = 8*2 = 16
  3. N is the minimal number resulting of computing 2b1-1 * 3b2-1 * 5b3-1 * ... for all the equivalent factorizations of d. Working the same example:
    N(16) = the minimal of these {2 * 3 * 5 * 7, 23 * 3 * 5, 23 * 33, 27 * 3, 215} = 23 * 3 * 5 = 120

更新:数字在 1020 左右,请注意同一页上引用的 Christian Bau 的注释。

关于寻找具有给定因子数的最小数的算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8861994/

相关文章:

c - 如果 m != n,确定 n^m = m^n 的最快方法是什么?

java - BST 字符串遍历

java - 简单java代码的时间复杂度

c++ - 使用索引 vector 重新排序 vector

matlab - 不重置参数的复杂角度计算 : continuous unbounded angle

algorithm - 需要数论优化

mysql - 如何存储MySQL的结果以便以后排序

java - 有没有办法在java控制台中对扫雷游戏的行和列进行编号?

r - 如何使用R将数字提取为数字?

python - 在 Python 2.5 到 2.7 中除以小数会产生无效结果