There are several syntax errors.
Clear[x, pnp, f];
f[x_] := ((x^3*pnp^2)/(pnp^2 + x) - x^3)
I don't understand how f
is going to compute semi-primes, its value is always negative so the loops never terminate.
Clear[pnp];
((x^3*pnp^2)/(pnp^2 + x) - x^3) // Simplify
(* -(x^4/(pnp^2 + x)) *)
Using built-in WL functions
Range[100] // AssociationMap[FactorInteger] //
Select[Total[#[[All, 2]]] == 2 &] // Keys
(* {4, 6, 9, 10, 14, 15, 21, 22, 25, 26, 33, 34, 35, 38, 39, 46, 49, 51,
55, 57, 58, 62, 65, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95} *)