Add ReturnOnInvestment to maths by InukaWijerathna · Pull Request #7446 · TheAlgorithms/Java
Thanks for the feedback! I've expanded the implementation to address the concern. The class now includes annualizedReturnOnInvestment(), which converts a total ROI over a multi-year holding period into an equivalent annual rate using the geometric-mean formula:
Annualized ROI = ((1 + ROI/100)^(1/n) - 1) x 100
This chains the simple ROI calculation, applies Math.pow with a fractional exponent, and validates an additional parameter (holding period in years). I've also added 8 new tests covering the one-year identity case, multi-year, fractional years, break-even, negative ROI, and invalid inputs. Happy to adjust further if needed!