Of course.
Here is an iterative method that calculates Triangle
int Triangle( int N )
{
int totalPins = 0;
for ( int row=1; row<=N; row++ )
totalPins += row;
return totalPins;
}
You might prefer it to the recursive version because the code looks familiar. But notice that it is not as clear that it implements the definition.
Is there a formula that gives Triangle(N)
immediately?