12 May 2017

Magical Well

My solution:
int magicalWell(int a, int b, int n) 
{
    var sum = 0;
    while (n != 0)
    {
        sum += a * b;
        a++;
        b++;
        n--;
    }

    return sum;
}

Previous Next