We're running a financial calculation in a simple programming language with limited built-in math functions.
We need to build two equations, one for purchasing an asset that increases slightly in value a flat percentile for every one of those assets you purchase, and one for the reverse.
The Buy() function only passes how much money you wish to spend, and gives you how many of that asset you could purchase with the amount you spend; assuming that each asset you buy is a percentage more expensive than the first one.
The Sell() function is in reverse , where you only put the amount of the asset you wish to sell and it returns how much money you would get by selling those assets assuming each one you sold was worth a percentage less than the one before it.
For Example, if i say want to throw $100 at this asset, and the asset's current price is 1 dollar. I need to know using a simple equation (multiplication and division preferably) how many of those assets i can buy if the value of each asset increases by a compound 1%.
Conversely, if i want to sell $100 of my asset at its current price of 1 dollar, i need to know how much I'll earn for 100 of those assets if each one sold decreases in value by 1%.
We feel this is a simple question, but lack the mathematics background to know what it's called and translate it into simple math equations.
Let's try buying. You spend $1.01^{n-1}$ on the $n$th asset you buy. The cost is a geometric series: $$\sum_{i=0}^{N-1}{1.01^i}=\frac{1.01^N-1}{0.01}$$ If you spend \$$X$, $$1.01^N=1+0.01X$$ So $$N=\frac{\log(1+0.01X)}{\log 1.01}$$
If you can't use logs, use the following process. Set $L=0$ and $U=1$. Double $U$ until $(1.01^U-1)/0.01\geq X$. Set $M=(L+U)/2$. If $(1.01^M-1)/0.01<X$, set $L=M$, else set $U=M$. I'm sure you see how this ends.