Skip to content

Instantly share code, notes, and snippets.

@frankchen0130
Created December 11, 2017 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankchen0130/162c1c9ecdbb827179f6813b55ee6367 to your computer and use it in GitHub Desktop.
Save frankchen0130/162c1c9ecdbb827179f6813b55ee6367 to your computer and use it in GitHub Desktop.
计算分期还款的实际利率
def calculateRealInterest(amount, months, percentPerMonth):
interestAmount = amount * percentPerMonth / 100 * months; #总手续费
amountPermonth = amount / months; #每期占用银行金额
occupyMonths = (1 + months) * (months / 2); #总占用月数
occupyYears = occupyMonths / 12; #占用年数
occupyAmountForOneYear = amountPermonth * occupyYears; #相当于占用了一年的金额
realInterest = interestAmount / occupyAmountForOneYear; #实际年化利率
return {
'总手续费': interestAmount,
'相当于占用了一年的金额': occupyAmountForOneYear,
'实际年化利率': realInterest
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment