Skip to content

Comments

feat: add equated monthly installments to financial#1020

Merged
siriak merged 1 commit intoTheAlgorithms:masterfrom
AliAlimohammadi:add-equated-monthly-installments
Feb 22, 2026
Merged

feat: add equated monthly installments to financial#1020
siriak merged 1 commit intoTheAlgorithms:masterfrom
AliAlimohammadi:add-equated-monthly-installments

Conversation

@AliAlimohammadi
Copy link
Contributor

@AliAlimohammadi AliAlimohammadi commented Feb 20, 2026

Description

Adds an implementation of the Equated Monthly Installment (EMI) calculation to the financial module. EMI is the fixed monthly payment a borrower makes to fully repay a loan over a given term, covering both principal and interest.

The formula used is:

$$A = \frac{p \cdot r \cdot (1 + r)^n}{(1 + r)^n - 1}$$

where $p$ is the principal, $r$ is the monthly interest rate (annual rate ÷ 12), and $n$ is the total number of monthly payments (years × 12). A zero-rate edge case is handled separately to avoid division by zero, returning principal / n directly.

Reference: Equated Monthly Installment — Wikipedia

Checklist:

  • I ran cargo clippy --all -- -D warnings just before my last commit and fixed any issue that was found.
  • I ran cargo fmt just before my last commit.
  • I ran cargo test just before my last commit and all tests passed.
  • I added my algorithm to the corresponding mod.rs file within its own folder, and in any parent folder(s).
  • I added my algorithm to DIRECTORY.md with the correct link.
  • I checked CONTRIBUTING.md and my code follows its guidelines.

@AliAlimohammadi
Copy link
Contributor Author

@siriak, this is ready to be merged.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.01%. Comparing base (39c6978) to head (b486dbe).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1020   +/-   ##
=======================================
  Coverage   96.01%   96.01%           
=======================================
  Files         383      384    +1     
  Lines       28852    28890   +38     
=======================================
+ Hits        27701    27738   +37     
- Misses       1151     1152    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak merged commit d14a4e2 into TheAlgorithms:master Feb 22, 2026
7 checks passed
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.

3 participants