# Mortgage calculator

**URL:** <https://forum.kirupa.com/t/mortgage-calculator/219566>\
**Category:** Uncategorized\
**Created:** [March 18, 2007, 12:14am UTC](https://forum.kirupa.com/t/mortgage-calculator/219566 "2007-03-18T00:14:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![deucescorner](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@deucescorner](https://forum.kirupa.com/u/deucescorner)\
**Post date:** [March 18, 2007, 12:14am UTC](https://forum.kirupa.com/t/mortgage-calculator/219566/1 "2007-03-18T00:14:03Z")

</div>

Hi,

So here goes my story; I’m creating a online mortgage calculator but had no idea the equation for mortgages was so complicated.

this is the equation i’m using: [COLOR=#ff0000]a = ( p \* r \* ( 1 + r )n ) / ( ( 1 + r)n - 1 )[/COLOR]

[COLOR=#ff0000][FONT=Verdana, Arial][SIZE=2][COLOR=red]p = [/COLOR][/SIZE][/FONT][/COLOR][COLOR=#ff0000][FONT=Verdana, Arial][SIZE=2][COLOR=darkgreen]is the principal[/COLOR][/SIZE][/FONT][/COLOR]  
[COLOR=#ff0000][FONT=Verdana, Arial][SIZE=2][COLOR=red]a = [/COLOR][/SIZE][/FONT][FONT=Verdana, Arial][SIZE=2][COLOR=darkgreen]is the payment per month[/COLOR][/SIZE][/FONT][/COLOR]  
[COLOR=#ff0000][FONT=Verdana, Arial][SIZE=2][COLOR=red]r = [/COLOR][/SIZE][/FONT][FONT=Verdana, Arial][SIZE=2][COLOR=darkgreen]is the interest rate per month[/COLOR][/SIZE][/FONT][/COLOR]  
[COLOR=#ff0000][FONT=Verdana, Arial][SIZE=2][COLOR=red]n = [/COLOR][/SIZE][/FONT][FONT=Verdana, Arial][SIZE=2][COLOR=darkgreen]is the number of months[/COLOR][/SIZE][/FONT][/COLOR]

I created 4 input boxes.

Instances names are:

1. amount = principal
2. years = for the number of years of the mortgage
3. percentage = the interest rate per year
4. total = obviously

here is my AS

```auto

calculate_btn.onRelease = function()
{
 total.text = (Number(amount.text) * ((Number(percentage.text)/100)/12) * (1 + ((Number(percentage.text)/100)/12)).exp(Number(yeare.text)*12))/((1 + ((Number(percentage.text)/100)/12)).exp(Number(yeare.text)*12))-1;
}

```

the answer i get isn “NaN”

I’m really not that familiar with actionscript but this is what i came up with, I’m basically trying to get the answer with 2 decimal points of course

can someone tell me what i’m doing wrong

thanks in advance
