You want a formula to solve the recursive formula F(n) = F(n-1) + ((n-1) * 5000)
There may be many ways to solve your question; consider this as one solution.
This answer uses a "custom formula" wa14322603()
.
- Enter the formula in a cell and point the input value to a cell containing an integer. The formula will return the value of the recursive formula.
/**
* Applies the input value to the recursive formula
*
* @param {number} input The value to use in the recursion
* @return The input applies to the recursion.
* F(0) = 0
* F(1) = 5000
* F(n) = F(n-1) + ((n-1) * 5000)
* @customfunction
*/
function wa14322603(input) {
// create a temporary array to hold values
var resultarray=[];
// assign F(0)
resultarray.push(0);
// assign F(1)
resultarray.push(5000)
// define the multiplier
var multiplier = 5000;
if (input===0){
var result = resultarray[input]
}
if (input === 1){
var result = resultarray[input]
}
if (input>1){
// calculate the number of tertaions required
var iterate=input+1;
for (var i=2; i<iterate;i++){
// calculate f(n-1}
var fn_1=resultarray.slice(-1);
// calculate n-1 * multiplier
var n_1multiplier = (+i-1)*multiplier
// add f(n-1) and n_1multiplier
var result = +fn_1+n_1multiplier;
// assign the result to the array
resultarray.push(result)
}
}
// return the last value in the array
return resultarray.slice(-1);
}
Example data showing breakdown of calculations