/* Calculate time it takes to double, triple, or any multiply factor to occurr in specified growth rate
* Copyright 2011 Sami Farin
* Released to Public Domain
*
* n = multiply factor
* r = rate of growth in percents
*
* to calculate what is the multiply factor to 1.75 in 3 time units:
* exp(ln(1.75)/3) = 1.205071
*
* probability of X happening is 1%, how many tries till chances are 50?
* ln(0.5)/ln(0.99) = ~68.967563
*
*/
config("resource_debug", 0),;
define fold()
{
local argc; /* number of args given */
local n;
local r;
local res;
argc = param(0);
if (argc != 2) {
quit "usage: fold(n [multiply factor], r [rate of growth in percents)";
}
n = param(1);
r = param(2);
if (n <= 0) {
quit "invalid n value";
}
res = ln(n)/ln(1+(r/100));
return res;
}