This page is still under construction.

Parts of this page are still being built. What you see may change.

Pyramids

Time limit1sMemory limit128 MB

Summary
For each positive base size n until a terminating 0, print the total number of blocks in a pyramid whose layers count down from n to 1.
Level

Easy1 of 10

Topics
Math, Implementation, Brute force, Array
Solved
No attempts yet

Problem

A pyramid of blocks is built by first laying a base layer of nn blocks, then placing n−1n-1 blocks on the layer above it. Each successive layer uses one fewer block than the layer below, and this continues until the top layer holds a single block.

Given the size of the base layer, determine the total number of blocks needed to complete the pyramid. For example, a pyramid whose base has size 44 needs 1010 blocks in total.

Input

The input is a sequence of integers, one per line. The end of the input is marked by the integer 00, which is not the base of any pyramid. Every integer except the final 00 is positive.

Output

For each positive integer, print the total number of blocks needed to build the pyramid whose base has that size, one result per line.

Examples1

  1. Example 1

    Input
    4
    6
    0
    
    Expected output
    10
    21