Skip to content

Instantly share code, notes, and snippets.

@bernardoduarte
Created February 28, 2023 17:41
Show Gist options
  • Save bernardoduarte/a7a951cd45443907731130363d1751e5 to your computer and use it in GitHub Desktop.
Save bernardoduarte/a7a951cd45443907731130363d1751e5 to your computer and use it in GitHub Desktop.
function jurosCompostosAporteMensal(valorInicial: number, aporteMensal: number, jurosMensais: number, periodoMeses: number): number {
const porcentagemJurosMensais = jurosMensais / 100;
const taxaJurosMensais = 1 + porcentagemJurosMensais;
const totalTaxaJurosPeriodo = taxaJurosMensais ^ periodoMeses;
const ganhoValorInicial = valorInicial * totalTaxaJurosPeriodo;
const ganhoAportesMensais = aporteMensal * (totalTaxaJurosPeriodo - 1) / porcentagemJurosMensais;
return ganhoValorInicial + ganhoAportesMensais;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment