Problem Description
"Given the triangle of consecutive odd numbers:
1
3 5
7 9 11
13 15 17 19
21 23 25 27 29
...
Calculate the row sums of this triangle from the nth row index (starting at row index 1)."CODING ARENA
#include <stdio.h>
int main()
{
int n,sum;
scanf("%d",&n);
sum=n*n*n;
printf("%d",sum);
return 0;
}
Test Case 1
Input (stdin)1
Expected Output1
Test Case 2
Input (stdin)2
Expected Output8
No comments:
Post a Comment