-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSum Nth Row.cpp
More file actions
36 lines (33 loc) · 646 Bytes
/
Sum Nth Row.cpp
File metadata and controls
36 lines (33 loc) · 646 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* Write a c++ program Sum Terms Nth Row.
Given a series as shown below:
1 2
3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18 19 20
..........................
............................
(so on)
You are given a number N, you need to write a program to find the sum of all elements in the N-th row of above series.
Example:
Input:
2
2
4
Output:
18
132
SUMIT KUMAR */
#include<iostream>
using namespace std;
int main()
{
int t,i,n,m;
scanf("%d",&t);
for(i=0;i<t;i++)
{
cin>>n;
m=((2*n*n)+1)*n;
cout<<m<<endl;
}
return 0;
}