# Computing interest

Page 1 of 1

## 7 Replies - 592 Views - Last Post: 15 October 2012 - 07:59 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=295460&amp;s=0cf4558168c61ccd1543c7114fbd9a94&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

Reputation: -2
• Posts: 92
• Joined: 12-November 10

# Computing interest

Posted 13 October 2012 - 07:06 AM

```Month=1
x = 100
v = 5000
z = (annualInterestRate)/12
while(balance >= 1):
balance = v
while(Month <= 12):
balance = (balance - x) * (1 + z)
Month+=1
x+=10
print('Lowest Payment: ' + str(x))
```

The above code is not working
i am trying to find the amount which is min required to pay each moth so that the credit amount at the end of 12 months should be 0 and the amount paid monthly should be fixed

Is This A Good Question/Topic? 0

## Replies To: Computing interest

### #2 atraub

• Pythoneer

Reputation: 825
• Posts: 2,207
• Joined: 23-December 08

## Re: Computing interest

Posted 13 October 2012 - 07:40 AM

Care to tell us what's wrong with it? Define "not working".

Reputation: -2
• Posts: 92
• Joined: 12-November 10

## Re: Computing interest

Posted 13 October 2012 - 07:48 AM

atraub, on 13 October 2012 - 07:40 AM, said:

Care to tell us what's wrong with it? Define "not working".

compiler is not showing any output

### #4 atraub

• Pythoneer

Reputation: 825
• Posts: 2,207
• Joined: 23-December 08

## Re: Computing interest

Posted 13 October 2012 - 08:42 AM

We can not see your computer screen. Would you care to copy and paste the error into your reply so that we can be on the same page? If you do, please use code tags.

Reputation: -2
• Posts: 92
• Joined: 12-November 10

## Re: Computing interest

Posted 14 October 2012 - 05:27 PM

atraub, on 13 October 2012 - 08:42 AM, said:

We can not see your computer screen. Would you care to copy and paste the error into your reply so that we can be on the same page? If you do, please use code tags.

```Month=1
x = 20
v = balance
z = (annualInterestRate)/12
i=0
while(v >= 1):
v = balance
Month = 1
for i in range(12):
v = (v - x) * (1 + z)
Month+=1
x+=10

x-=10
print('Lowest Payment: ' + str(x))

```

The above code works fine but i have to make it through bisection search.
I don`t know where to start for it

### #6 atraub

• Pythoneer

Reputation: 825
• Posts: 2,207
• Joined: 23-December 08

## Re: Computing interest

Posted 14 October 2012 - 07:27 PM

do you know what bisection search is? can you describe how it works, step-by-step? Pretend I have no idea how it works.

Reputation: -2
• Posts: 92
• Joined: 12-November 10

## Re: Computing interest

Posted 15 October 2012 - 06:24 AM

atraub, on 14 October 2012 - 07:27 PM, said:

do you know what bisection search is? can you describe how it works, step-by-step? Pretend I have no idea how it works.

step 1:
we assume 2 points 1) - lower bound
2) - Upper bound

lower bound has the lowest possible value
upper bound has the largest possible value

step 2:

we add both of them and divide by 2

step 3:

now if the possible value is in the middle ie what we get after dividing or whether it is below or above it

step 4:

if the value is above the answer then we make the answer the lower bound and the upper bound remains the same or vise-verse

step 5:

repeat these steps until found

### #8 atraub

• Pythoneer

Reputation: 825
• Posts: 2,207
• Joined: 23-December 08

## Re: Computing interest

Posted 15 October 2012 - 07:59 PM

Very good, now of these steps, which ones are you unsure how to translate into code?

EDIT:
I don't understand 3 and 4... you say we do something if a certain condition is true... but you never say what we're suppose to do.

This post has been edited by atraub: 15 October 2012 - 08:00 PM