12 May 2017

Apple Boxes

My solution:
int appleBoxes(int k) 
{
    return Enumerable.Range(1, k).Select(i => Convert.ToInt32(Math.Pow(-1, i) * Math.Pow(i, 2))).Sum();
}

Previous Next