Skip to content

Instantly share code, notes, and snippets.

@DK070202
Created January 17, 2024 12:38
Show Gist options
  • Save DK070202/565f176bc38a7d83c1bf256424c1d60b to your computer and use it in GitHub Desktop.
Save DK070202/565f176bc38a7d83c1bf256424c1d60b to your computer and use it in GitHub Desktop.
crimson-echo-1254
import 'dart:math';
int calculateMaturityValue(double P, double i, int n) {
double compoundInterest = ((pow(1 + i, n) - 1) / i) * (1 + i);
double M = P * compoundInterest;
return M.round();
}
void main() {
double principalAmount = 1000; // Amount
int numberOfPeriods = 365;
double interestRate = 0.08 / numberOfPeriods; // Assuming monthly compounding
int numberOfYear = 1; // Number of years.
int numberOfInvestments = numberOfYear * numberOfPeriods;
final maturityValue = calculateMaturityValue(
principalAmount, interestRate, numberOfInvestments);
print("Maturity Value (M): Rs $maturityValue");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment