Message Boards Message Boards


Looking for a tip on a balance calculation

Posted 3 years ago
2 Replies
2 Total Likes

Hello! I'm looking for some help on a short function I'm writing. I am working on creating a function that given four inputs (principle balance, yearly interest rate, monthly payment, and number of months) and will output a list of the balances of a loan at the end of each payment period. I understand that this is relatively elementary but I am new to Mathematica. Also, this is something I'm creating to learn more about mathematica for a course, so I am not looking to have my code written/edited for me. If someone can explain to me what is wrong with my logic or syntax I'd very much appreciate it. A screenclip of my function is below.

enter image description here

2 Replies

I can't see syntax errors. I would use lower-case letters for symbols, so that I am sure they don't conflict with built-in functions. You have an opportunity to use NestList:

loanBalanceCalculation2[principal_, yearlyRate_, payment_, months_] :=
  NestList[# + yearlyRate/(12*100) # - payment &, principal, months]

Those parenthesis look suspiciously large. Why don't you select the cell and convert it to InputForm (Cell->Convert->InputForm) and see what you get? In any case you should really be using lower case variables and Module[{owed}, (...etc..) ] instead of the parenthesis.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract