Returned to calculating all triangles in C