Skip to content

Add ReturnOnInvestment to math#806

Open
InukaWijerathna wants to merge 2 commits into
TheAlgorithms:masterfrom
InukaWijerathna:add/return-on-investment
Open

Add ReturnOnInvestment to math#806
InukaWijerathna wants to merge 2 commits into
TheAlgorithms:masterfrom
InukaWijerathna:add/return-on-investment

Conversation

@InukaWijerathna
Copy link
Copy Markdown

Description

Adds ReturnOnInvestment to the math package.

ROI is a straightforward but widely used financial calculation that measures investment profitability:

ROI = (Gain - Cost) / Cost × 100

What's included

  • math/returnoninvestment.go — returns (float64, error), following Go idioms
  • math/returnoninvestment_test.go — table-driven tests covering all cases including error paths

Checklist

  • Follows Go conventions (exported function, error return, package-level test)
  • Table-driven tests with descriptive names
  • Returns error (not panic) for invalid input

Reference: https://www.investopedia.com/terms/r/returnoninvestment.asp

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Jun 5, 2026

Not up to standards ⛔

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@InukaWijerathna
Copy link
Copy Markdown
Author

InukaWijerathna commented Jun 5, 2026

Closing this for now — needs more work on my end before it's ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant