Given the value of n, we need to find the sum of the series where i-th term is sum of first i natural numbers.
NOTE: Sum of the series 1 + (1+2) + (1+2+3) + (1+2+3+4) + …… + (1+2+3+4+…+n)
Example 1:
Input: n = 5
Output: 35 
Explanation: 1 + (1+2) + (1+2+3).. = 35
Hence sum of the series is 35.
Example 2:
Input: n = 10
Output: 220
Explanation: 1 + (1+2) + (1+2+3) +
(1+2+3+4) + (1+2+3+4+5)... = 210.
Hence sum of the series is 210.
Your Task:  
You dont need to read input or print anything. Complete the function sumOfTheSeries() which takes n as input parameter and returns the sum of the series of n terms.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
1<= n <=1000

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:

    def sumOfTheSeries (self, n):

        # code here 

Solutions:
class Solution:

	def sumOfTheSeries(self, n):
		return int(n * (n + 1) * (n + 2) / 6)


class Solution:

	def sumOfTheSeries(self, n):
		l = []
		for i in range(1, n + 1):
			l.append(i * (i + 1) // 2)
		return sum(l)


class Solution:

	def sumOfTheSeries(self, n):

		def s(x):
			return x * (x + 1) // 2
		c = 0
		for i in range(1, n + 1):
			c += s(i)
		return c


class Solution:

	def sumOfTheSeries(self, n):
		k = 0
		j = 0
		for i in range(n):
			k += i + 1
			j += k
		return j


class Solution:

	def sumOfTheSeries(self, n):
		ans = n * (n + 1) * (n + 2) // 6
		return ans


class Solution:
	s = 0

	def sumOfTheSeries(self, n):
		return int(n * (n + 1) * (n + 2) / 6)


class Solution:

	def sumOfTheSeries(self, n):
		cur = 0
		i = 0
		for x in range(1, n + 1):
			cur = cur + x
			i += cur
		return i


class Solution:

	def sumOfTheSeries(self, n):
		a = int(n)
		k = a ** 2 * (a + 1) / 2 - (a ** 2 - 1) * a / 3
		return int(k)


class Solution:

	def sumOfTheSeries(self, n):
		sum = 0
		for i in range(1, n + 1):
			sum += i * (i + 1) // 2
		return sum


class Solution:

	def sumOfTheSeries(self, n):
		count = 0
		res = 0
		for i in range(n + 1):
			count += i
			res += count
		return res


class Solution:

	def sumOfTheSeries(self, n):
		sum_of_n_term = n * (n + 1) * (n + 2) // 6
		return sum_of_n_term


class Solution:

	def sumOfTheSeries(self, n):
		if n == 1:
			return 1
		else:
			return n * (n + 1) // 2 + self.sumOfTheSeries(n - 1)


class Solution:

	def sumOfTheSeries(self, n):
		j = n
		sum = 0
		while j >= 1:
			sum = sum + n * (n + 1) / 2
			n = n - 1
			j = n
		return int(sum)


class Solution:

	def sumOfTheSeries(self, n):
		sum1 = 0
		for i in range(1, n + 1):
			sum1 += i * (i + 1) / 2
		return int(sum1)


class Solution:

	def sumOfTheSeries(self, n):
		ans = 0
		c = 0
		for i in range(1, n + 1):
			c += i
			ans += c
		return ans


class Solution:

	def sumOfTheSeries(self, n):
		res = n * (n + 1) * (n + 2) // 6
		return res


class Solution:

	def sumOfTheSeries(self, n):
		s = 0
		for i in range(1, n + 1):
			e = i * (i + 1) // 2
			s += e
		return s


class Solution:

	def sumOfTheSeries(self, n):
		l = []
		y = 0
		for x in range(1, n + 1):
			l.append(x)
			y = y + sum(l)
		return y


class Solution:

	def sumOfTheSeries(self, n):
		return n * (n + 1) * (2 * n + 4) // 12
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		n = int(input())
		ob = Solution()
		print(ob.sumOfTheSeries(n))


class Solution:

	def sumOfTheSeries(self, n):
		total = 0
		for itr in range(1, n + 1):
			total += itr * (itr + 1) // 2
		return total
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		n = int(input())
		ob = Solution()
		print(ob.sumOfTheSeries(n))


class Solution:

	def sumOfTheSeries(self, n):
		m = n * (n + 1) * (n + 2)
		return m // 6
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		n = int(input())
		ob = Solution()
		print(ob.sumOfTheSeries(n))


class Solution:

	def sumOfTheSeries(self, n):
		s = 0
		for i in range(1, n + 1):
			s += i * (i + 1) // 2
		return s
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		n = int(input())
		ob = Solution()
		print(ob.sumOfTheSeries(n))


class Solution:

	def sumOfTheSeries(self, n):
		tot = 0
		for i in range(n + 1):
			tot += (n - i) * (i + 1)
		return tot


class Solution:

	def sumOfTheSeries(self, n):
		sum = 0
		for x in range(1, n + 1):
			sum += x * n
			n -= 1
		return sum


class Solution:

	def sumOfTheSeries(self, n):
		ret = n * (n + 1) * (n + 2) // 6
		return ret


class Solution:

	def natural(self, n):
		return n * (n + 1) // 2

	def sumOfTheSeries(self, n):
		summ = 0
		for _ in range(1, n + 1):
			summ += self.natural(_)
		return summ


class Solution:

	def sumOfTheSeries(self, n):
		s = 0
		k = 1
		l = []
		while n > 0:
			s = s + k
			k = k + 1
			l.append(s)
			n = n - 1
		return sum(l)


class Solution:

	def sumOfTheSeries(self, n):
		s = 0
		while n != 0:
			s = s + n * (n + 1) // 2
			n = n - 1
		return s


import math

class Solution:

	def sumOfTheSeries(self, n):
		return int(n * (n + 1) * (2 * n + 4) / 12)


import math

class Solution:

	def sumOfTheSeries(self, n):
		sum = 0
		ans = 0
		for i in range(1, n + 1):
			sum += i
			ans += sum
		return ans


class Solution:

	def sumOfTheSeries(self, n):
		sum = 0
		m = 1
		sum2 = 0
		while m <= n:
			sum = sum + m
			sum2 = sum2 + sum
			m = m + 1
		return sum2


class Solution:

	def sumOfTheSeries(self, n):
		a1 = 1
		c = 0
		for i in range(n):
			s = 2 * 1 + (a1 - 1) * 1
			s1 = s * a1 // 2
			c = c + s1
			a1 += 1
		return c


class Solution:

	def sumOfTheSeries(self, n):
		l = []
		l1 = []
		for i in range(1, n + 1):
			l.append(i)
		for k in range(1, len(l) + 1):
			l1.append(sum(l[0:k]))
		return sum(l1)


class Solution:

	def sumOfTheSeries(self, n):
		k = n * (n + 1) * (n + 2) // 6
		return k


global l

class Solution:

	def sumOfTheSeries(self, n):
		tn = n
		t = 0
		for j in range(1, n + 1):
			t += j * tn
			tn -= 1
		return t


global l
l = []
for j in range(1, 1001):
	l.append(j * (j + 1) // 2)

class Solution:

	def sumOfTheSeries(self, n):
		return sum(l[0:n])


class Solution:

	def sumOfTheSeries(self, n):
		if n == 1:
			return 1
		return int(n * (n + 1) / 2) + self.sumOfTheSeries(n - 1)


class Solution:

	def sumOfTheSeries(self, n):
		ls = []
		ans = 0
		for i in range(n):
			ans += i + 1
			ls.append(ans)
		return sum(ls)


class Solution:

	def sumOfTheSeries(self, n):
		if n > 1:
			return self.sumOfTheSeries(n - 1) + sum(range(n + 1))
		else:
			return 1


class Solution:

	def sumOfTheSeries(self, n):
		s = 0
		for x in range(1, n + 1):
			s += x * (x + 1) / 2
		return int(s)


class Solution:

	def sumOfTheSeries(self, n):
		su = 0
		while n > 0:
			su += (n * n + n * 1) // 2
			n -= 1
		return su