I have an optimization problem that I'm currently solving by brute force, but I'm hoping there is a better way.
Problem: Given n
and d
, find prime powers p1^e1, ..., pk^ek
(pi
s are distinct) such that
p1^e1 * ... * pk^ek >= n^d
p1^e1 + ... + pk^ek < n
is minimalMy current solution is to iterate through all possible subsets of primes (up to some fixed number), then iterate through all possible exponents (up to some fixed number), then test condition 1, then see if the sum is the smallest so far. This takes a really long time. Is there something more clever that I can do to speed this up?
This seems like a knapsack problem. I suspect it is NP-complete. In fact, if (d = 1), an optimization might be equivalent to factoring.
Not all Knapsack problems are NP-hard however - which is why the Merkle–Hellman knapsack cryptosystem was broken.