Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
loan
#41
I totally understand what you are writing, and that's what I do if I already have all four values
and want to find out the balance after n years.
But now I need to calculate A, so I cannot write what it is if the code is supposed to find out.
So the question is: how do I calculate A?
Reply
#42
(Apr-07-2019, 12:00 PM)mcgrim Wrote: All I am trying to do is to calculate A, how large does it need to be in order for the last element
of the list to be either 0 or a negative number?

This will tell you the balance after n years:

def f(balance, r, A, n):
    for year in range(n):
        balance = balance * (r / 100.0 + 1) - A
    return balance
If you want to calculate A such that the balance is positive using this, you would need to run it with different values of A until you got a positive balance.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#43
I think ichabod's post is very useful, but I will also say that you may want to Google "binary search" as it seems well-suited to your problem.
Reply
#44
Well, there's also a simple formula that solves this problem.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#45
to ichabod801:
The code you wrote above is the one I already had.
I totally understand what you are saying but perhaps you misunderstood my question.
I am actually looking to write a code where A is an output.
Makes sense?
Reply
#46
what would be the formula for A ? If you believe you cannot give me a straight answer, may you perhaps write a code concerning something similar ?
Reply
#47
It's a load calculation. Do a web search for the formula for loan payments and you'll find it.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#48
I don't need a new formula, I am using the one I have, I just have to change it in a way so A is the output, but I don't know how.
On the interned I can only find different formulas for the loan payment, not exactly this one, and no formula found returns A. If you are aware of a website that has what I need, please share.
Reply
#49
(Apr-08-2019, 08:48 PM)mcgrim Wrote: On the interned I can only find different formulas for the loan payment, not exactly this one, and no formula found returns A.

'A' is the loan payment.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#50
not exactly.
A is a fixed amount that is paid every year.
Every year you pay something from which A is subtracted (see formula on the code)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020