Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
Hey guys, back when I posted the clock program, I got a lot of good feedback of how to optimise the program. And I'm back at it again, This time, with a compounding interest calculator that simulates percent growth daily, and I even implemented saving money per day. The only problem is, that it runs absurdly slow and I want to optimise it. This was originally written for the V200 and it ran even slower on there. I tried <<translating>> the code to TI84-BASIC in hopes it would be more accessible to the many. If you guys want the original code, I can edit it into the OP.

Thanks ahead of time for your guys' help!

Here's The Code for Ti-84/83:

Code:

//Setup
ClrHome
0->T:0->I
0->M:0->C:0->E
0->L:0->P:0->D
Fix 2

//Splash
Disp "The Power of Compounding"
Disp "by: Ajzek Mejer"
Pause
ClrHome

//Input
Input "Bal? ",C
Input "%? ",P
Input "Yrs? ",L
Input "Dollar? ",D
P/365->P

//Calculate
ClrHome
Disp "Caculating..."
Disp ""
If D=0
Then
 For(T,1,L,1
  For(I,0,365,1
   (P+1)*C->C
  End
  Disp "Yr:",T
  Disp "Bal:",C
  Disp ""
 End
End
If D=1
Then
 Input "How Many $? ",M
 For(T,1,L,1
  For(I,0,365,1
   C+M->C
   (P+1)*C->C
  End
  Disp "Yr:",T
  Disp "Bal:",C
 End
End
Pause
C->E

//Final
ClrHome
Disp "Final Bal:",E
Izder456 wrote:

Code:
For(I,0,365,1
   (P+1)*C->C
End

This part is garbage and its what's making everything super slow since you have this nested in another loop. Just use the compound interest formula instead of calculating each day one at a time.
mr womp womp wrote:
Just use the compound interest formula instead of calculating each day one at a time.


how would I do that?
You just use the compound interest formula. We can link you a google link with the formula, or you can look it up yourself Wink
MateoConLechuga wrote:
You just use the compound interest formula. We can link you a google link with the formula, or you can look it up yourself Wink

ok thanks!

EDIT:
Like this?

Code:

For(T,1,L,1
 (p+1)*(c*365)->c
 Disp "Yr:",T
 Disp "Bal:",C
 Disp ""
End


EDIT2:
oof i messed up.

Is there a way I can do a time.sleep() like thing like in python in ti-basic? It spams results and you cannot read it

EDIT3:
or maybe:

Code:

For(T,1,L,1
 ((p+1)+(c))*365->c
 Disp "Yr:",T
 Disp "Bal:",C
 Disp ""
End

as you can see math isn't my strong suit and need help.

EDIT4:

Code:

root(p,365)->p
...
For(T,1,L,1
 (p+1)*(c)->c
 Disp "Yr:",T
 Disp "Bal:",C
 Disp ""
End


i don't know how to write roots in tokens so i wrote it like 68k basic

EDIT5:
if we assume that the user adds one wanting to appreciate the value instead of depreciate
we can use:

Code:

root(p,365)->p
...
For(T,1,L,1
 (p)*(c)->c
 Disp "Yr:",T
 Disp "Bal:",C
 Disp ""
End
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement