SUM from 1 to n in EXCEL

Solved
Julien -  
 To -
Hello,
I would like to sum the a^i, with i going from 1 to n, in a single Excel cell.
In expansion, this would give: a^0 + a^1 + a^2 + ... + a^n.

I've been looking for a while, and I'm stuck...

Thank you in advance for your help
Configuration: Windows Vista Firefox 3.0.13

6 answers

  1. dobo69 Posted messages 1593 Registration date   Status Member Last intervention   835
     
    Hello,

    In Excel, the formula does not exist, so you need to create it:
    In a module (like a macro), write the code for this function (which I called sommepuiss in the example below)

    Function sommepuiss(V, n) For i = 0 To n sommepuiss = sommepuiss + V ^ i Next i End Function 

    Then, in the Excel sheet, use it as a "classic" function:

    If a is in A1 and n in A2, for example, you should write in the cell where you want the result:

    =sommepuiss(A1;A2)

    --

    If you need anything else, just let me know.
    13
    1. amgg95
       
      Hello! I read your response, and I wanted to ask you a question:
      I would like to create a function in Excel that allows me to perform a "while" loop (it's for an algorithm). And I find that a "while K <= N" loop is like "for K from 1 to N"
      Since I can't find the "while" loop, I'm leaning more towards the second solution
      However, I'm not sure about the code to enter when creating my function, and a bit of help from someone who knows would not be too much.

      Thank you in advance, and have a good day!
      0
    2. To
       
      You're welcome!!!
      0