Equilateral Triangle in a Grid

An equilateral triangle with an integer number of n equidistantly distributed ‘dots’ along each side, forms a ‘triangle grid’ of uniformly distributed ‘dots’ within the boundary of this equilateral triangle. The figure below illustrates such a ‘triangle grid’ for the example n = 4. Question: How many different equilateral triangles can be found in this ‘triangle grid’ when the vertexes of each equilateral triangle must always be ‘dots’ of the ‘triangle grid’? Note: Take into account that the equilateral triangles come with multiple sizes and orientations! Input Each line of the input file contains a single integer n denoting the number of ‘dots’ along each side of the equilateral triangle (2 ≤ n ≤ 100). The input is terminated by a line containing a single zero. Input file will contain less than 20 lines. Output For each line of input produce one line of output. This line should contain the number of different equilateral triangles that can be found in the ‘triangle grid’ of the size specified by the according input line. Sample Input 2 3 0 Sample Output 1 5