I need to solve for the smallest positive integer $s$ such that the following is satisfied for $p>1, napprox infty, epsilon>0$

$$frac{sum_{i=1}^n left(1-i^{-p}right)^si^{-p}}{sum_{i=1}^n i^{-p}}le epsilon$$

Using `FindRoot`

for this problem sometimes fails because it tries negative $s$. There’s an 8-year old answer for adding dynamic constraints to `FindRoot`

but looks a bit awkward, is it still the best way to do it?

```
solve(p_, n_, eps_) := (
formula(s_) =
1/ HarmonicNumber(n, p) Sum((1 - 1/i^p)^s 1/i^p, {i, 1, n});
invert(f_) :=
FindRoot(f(s) == eps, {s, 2}, AccuracyGoal -> 4,
PrecisionGoal -> 4);
invert(formula)
);
solve(6, 1000, 10^-2) (* works *)
solve(7, 1000, 10^-2) (* fails *)
```