Search code examples
libreoffice-calc

how to enter a recursive formula in libreoffice


I am making a spreadsheet in LibreOffice for a game I play. I have various monsters that I level up by giving them food. The food required doubles for each level. I want to have column A represent their current level, column be to represent how much food each monster needs for the next level and C to be the level I want to get them to. I can easily enter a formula for how much food will be needed at the top level, but I don't know how to enter a formula that adds up all the food required. Any help would be appreciated.


Solution

  • You need to sum a geometric series. In this case, the formula can be simplified to:

    =B1 * (POWER(2, C1-A1) - 1)
    

    For example, let's say food required to level up is 15, and we want the monster to go from level 5 up to 8, doubling the requirement each level. Then the monster would need 15 * (1 + 2 + 4) = 105 food.