Practice for Basic C++
<p>This is a practice question I'm having trouble answering. Anybody have a clue about the formula? I was thinking sum of the numbers as so.. 2^0 + 2^1 + 2^2 ... 2 ^ n ?
What is the (sign = -sign; ) used for? Thanks for anyone that can give some assistance.</p>

<p>Give a description of the mathematical formula that the following function computes.</p>

<pre><code>// Pre: n&gt;=0
// Post: ???
double WhatAmI(int n) {
    int result=0;
    int ctr=0;
    int sign = 1;
    while(ctr&lt;=n) {
        result = result + power(2,ctr);
        sign = -sign;
        ctr++;
    }
    return result;
}
</code></pre>
