HP Forums
STUPID BUTUSEFUL CHALLENGE #879 - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: STUPID BUTUSEFUL CHALLENGE #879 (/thread-19666.html)



STUPID BUTUSEFUL CHALLENGE #879 - Thibaut.be - 07-05-2002

The formula for constant annuity (TVM reimbursement) is :

a = PV * i / (1-(1+i)^-n)

write a program in as few possible steps to solve this equation, where you have previously entered the following variables in the stack : PV (= present value or lended amount, i (= interest (not in %, ie 6% = .06), n (number of payments

NB :
European people :
i has to be converted from the basic rate. If rate is anuual and payments are monthly, then im = 1-(1+iy)^(1/12)

American people :
the shown rate is different from the yield, but the monthly rate is calculated by dividing the annual rate by 12, so im=iy/12

Thibaut


Re: STUPID BUT USEFUL CHALLENGE #879 - Thibaut.be - 07-05-2002

Oops, I posted the message above to fast.

- the PV, n and i vlaues can be stored wherever you want
- hint : use no register (sto and rcl cost bytes !), but do use the stack. BTW, this is an excellent stack exercice.

My solution is 15 steps long, including LBL/RTN. Who give a better one ?

It could be 17 steps long with a 12C for the rollup function does not exist in the 12C (you spend 2 more bytes * 2) but the lbl and rtn funtions do not exist either (you save 2 bytes)


Amazing how fast the answer is given on a 41C (< 1sec) and on a 12C (<2.5 sec, v. <2 sec with the solver)

Enjoy !


13 steps - listing included...don't read unless you want to see it! - Gene - 07-05-2002

Ok, to make up for NOT READING the earlier challenge completely (I used a numeric key), I have a 41c style solution with 13 steps, including LBL and RTN.

My inputs are n, PV, and i in the Z, Y, and X registers. I assumed that n is total number of payments and i was the periodic interest rate...if the payments are monthly then i is the monthly interest rate.

Interestingly, I have 15 step solutions for PV, n, i and PV, i, n as the input order.

LBL 01
x
Lastx
1
+
RUP (Roll Up)
CHS
Y^x
1
-
CHS
Divide
RTN

That seems to work. Anyone less than 13?
Gene




Re: 13 steps - listing included...don't read unless you want to see it! - Ed Martin - 07-05-2002

This is cheating ... a bit.

If you put -n on the stack instead of N, you can do it in 12 steps:

LBL 01
*
LASTx
1
+
RUP
y^x
CHS
1
+
/
RTN

- Ed


My solution... - Thibaut.be - 07-06-2002

Also 13 steps, without LBL and RTN, with n in Z, PV in Y and i in X :

LBL A
ENTER
Roll Down
*
Roll Up
1
+
Roll Up
CHS
y^x
1
-
CHS
/
RTN


Re: STUPID BUTUSEFUL CHALLENGE #879 - Jim Kimes - 07-07-2002

I suggest that when such challenges are posted--and they can be quite useful--a solved example be included so that the challengees will know positively they've understood the problem and exactly what kind of problem it is they're challenged to solve. In this case I could have produced a formula but I wouldn't have known for sure that the formula was exact without a sample by which to proof my work. Thanks.


Re: STUPID but Useful Challenges - Paul Brogger - 07-08-2002

I would think that the creative finance people from Enron and WorldCom could put their vast experience to use and contribute a few helpful hints under this Subject line . . .


Re: STUPID BUTUSEFUL CHALLENGE #879 - Thibaut.be - 07-08-2002

example :

You purchase a house for $500.000.
You pay it back in 15 years. Rate is 5.5/year.

Month rate is .05/12=0.42%/month. 15 years is 180 month

Key in
180 ENTER 500.000 ENTER .0042 R/S (or XEQ...)

Your should read a monthly payment of 3.964,39 per month...




Re: STUPID BUTUSEFUL CHALLENGE #879 - Jim Kimes - 07-12-2002

Thanks for the example. Helps immensely.