math
Moderators: heatherlaine, Klaus, FourthWorld, kevinmiller

 Posts: 8
 Joined: Thu Aug 30, 2018 8:51 am
math
Hi there,
I'm trying to make a function to process a number through a formula:
1000000/((((1+10%)^(67 {the number} ))1)/10%)
btw this number can be changed by the user, and then there'll be a different result.
Thanks for your help,
Aviv
I'm trying to make a function to process a number through a formula:
1000000/((((1+10%)^(67 {the number} ))1)/10%)
btw this number can be changed by the user, and then there'll be a different result.
Thanks for your help,
Aviv
Re: math
Hi Aviv,
welcome to the forum!
Hm, I don't see a question!?
And what is the 10% of? > ...1+10%...
10% of what?
Best
Klaus
welcome to the forum!
Hm, I don't see a question!?
And what is the 10% of? > ...1+10%...
10% of what?
Best
Klaus

 Livecode Opensource Backer
 Posts: 2714
 Joined: Fri Feb 19, 2010 10:17 am
 Location: Bulgaria
 Contact:
Re: math
Just possibly "1+10%" should be 1.1 and "10%" should be 0.1
although the whole thing is hard to understand.
although the whole thing is hard to understand.

 Posts: 8
 Joined: Thu Aug 30, 2018 8:51 am
Re: math
This formula's result is how much money you need to invest in the NASDAQ per year to have 1M dollars by retirement, this is not something that I can change, the number that changes by user of the app is his age. his age the part of the formula that changes I need to insert a number that the user gave and run it in this formula and show the result.
Thanks of your help,
Aviv
btw I dont hv a clue what the 10% is of.
Thanks of your help,
Aviv
btw I dont hv a clue what the 10% is of.

 VIP Livecode Opensource Backer
 Posts: 5526
 Joined: Wed May 06, 2009 2:28 pm
 Location: New York, NY
Re: math
Conceptually, there must be a reason.
Programmatically, know that the function will fail, due to the "%" as part of the argument. LC will not allow:
How that should be changed (0.1?) is a question.
Craig
Programmatically, know that the function will fail, due to the "%" as part of the argument. LC will not allow:
Code: Select all
put 4/10%
Craig
Re: math
This is what hh is referring to 
Lc Dictionary wrote: Use the annuity function to calculate the present or future value of an annuity or to calculate loan payments.
The formula for the value of an ordinary annuity is
(1  (1 + *interestRate*)^( *numberOfPeriods*))/ interestRate
The annuity function calculates this value.
The numberOfPeriods and the interestRate must use the same unit of time. For example, if the periods are months, the interest rate is the interest per month.
You can use the annuity function to calculate the amount of loan payments as follows:
paymentAmount = totalAmount/annuity(rate,periods)
For example, if the loan is for $2500 at an interest rate of 2% per month and is to be repaid in a year, the monthly payment is 2500/annuity(.02,12) or $236.40.

 VIP Livecode Opensource Backer
 Posts: 1761
 Joined: Thu Feb 28, 2013 11:52 pm
 Location: Göttingen, DE
Re: math
To use exactly your formula (with the exorbitant interest rate):
Code: Select all
on mouseUp
put fld "input" into age  contains the age in years
put max(1,67age) into x  avoid division by zero
put 1000000 into v  the target amount
put 0.1 into r  the interest rate 10% of one = 0.1
put yearlyAmount(x,r,v) into fld "output"
end mouseUp
function yearlyAmount x,r,v
put v/((((1+r)^x)1)/r) into ann
return format("%.2f",ann)  cash format = two digits
end yearlyAmount
shiftLock happens

 Posts: 8
 Joined: Thu Aug 30, 2018 8:51 am
Re: math
oh my god! thank you very much! you're a life saver! <3
a big thanks to all of those who tried! you've helped me too!
a big thanks to all of those who tried! you've helped me too!

 Posts: 8
 Joined: Thu Aug 30, 2018 8:51 am
Re: math
Code: Select all
put max(1,67age) into x  avoid division by zero
excution error at line 21 (Operators : error in right operand), char 1
it worked a minute ago, I didn't change anything then it didn't work.
thanks again,
Aviv
Re: math
Hi Aviv,
make sure > age is a number, resp. check what is really in field "input".
If everything is OK, just quit Livecode and start again, helps most of the time.
Hint for the future:
If you do not know the task exactly (or have no idea whatsoever), it is hard to find a solution for it!
Unless you have Hermann in your crew.
Best
Klaus
make sure > age is a number, resp. check what is really in field "input".
If everything is OK, just quit Livecode and start again, helps most of the time.
Hint for the future:
If you do not know the task exactly (or have no idea whatsoever), it is hard to find a solution for it!
Unless you have Hermann in your crew.
Best
Klaus
Re: math
Hi Craig,
this IS in fact a number, in most european countries, but please look up the MAX() function in the dictionary.
Aviv, maybe some parens will help:
...
put max(1,(67age)) into x
...
Best
Klaus
this IS in fact a number, in most european countries, but please look up the MAX() function in the dictionary.
Aviv, maybe some parens will help:
...
put max(1,(67age)) into x
...
Best
Klaus

 Posts: 8
 Joined: Thu Aug 30, 2018 8:51 am
Re: math
hi Klaus,
I did as you suggested but still, no luck.
it didn't help,
do you have another way to solve problems like this?
Aviv
I did as you suggested but still, no luck.
it didn't help,
do you have another way to solve problems like this?
Aviv