Suppose we would like to compute an approximate prime factorization of a large integer `x`

in the sense that the difference of `x`

and its approximation is minimized. A naive way to state the problem in Mathematica is as follows.

```
n = 50;
x = RandomInteger[10^100];
vars = Map[Symbol["z" <> ToString[#]] &, Range[n]];
f = Abs[Times@@Map[Prime[#]^Symbol["z" <> ToString[#]] &, Range[n]] - x];
cons = Map[# >= 0 &, vars];
NMinimize[{f, cons}, vars [Element] Integers]
```

The result is not very convincing and simply increasing `n`

does not help. Do you have a better way to solve the problem?