Given a series of numbers  3,10,21,36 …., and series starting from N = 1, find the pattern and output the N'th value of the above series.
Example 1:
Input:
N = 1
Output:
3
Explanation:
3 is the first term of the series.
Example 2:
Input:
N = 2
Output:
10
Explanation:
10 is the second term of the series.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function differenceSeries() which takes an integer N as input parameter and returns the N'th term of the series.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ n ≤ 100

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def differenceSeries(self, N):

    	#code here 

Solutions:
class Solution:

	def differenceSeries(self, N):
		s = N * (2 * N + 1)
		return s


class Solution:

	def differenceSeries(self, n):
		return n * (3 + (n - 1) * 2)


class Solution:

	def differenceSeries(self, N):
		return N * (N + 1) + N * N


class Solution:

	def differenceSeries(self, N):
		return 2 * N * N + N


class Solution:

	def differenceSeries(self, N):
		if N == 0:
			return 0
		a = 3
		d = 7
		count = 1
		while count < N:
			a += d
			d += 4
			count += 1
		return a


class Solution:

	def differenceSeries(self, N):
		s = 3
		k = 7
		if N == 1:
			return s
		else:
			c = 1
			while c < N:
				s = s + k
				k += 4
				c += 1
		return s


class Solution:

	def differenceSeries(self, n):
		l = [3, 10]
		for i in range(2, n):
			l.append(l[i - 1] + 7 + 4 * (i - 1))
		return l[n - 1]


class Solution:

	def differenceSeries(self, N):
		s = [3, 10]
		if N == 1:
			return 3
		elif N == 2:
			return 10
		else:
			for i in range(N):
				s.append(s[i + 1] - s[i] + 4 + s[i + 1])
		return s[N - 1]


class Solution:

	def differenceSeries(self, N):
		if N < 0:
			return 0
		j = 3
		for i in range(1, N + 1):
			k = i * j
			j += 2
		return k


class Solution:

	def differenceSeries(self, n):
		num = 2 * n ** 2 + n
		return num


class Solution:

	def differenceSeries(self, N):
		c = 0
		for i in range(1, N + 1):
			c += 3 * i + (i - 1)
		return c


class Solution:

	def differenceSeries(self, N):
		if N > 1:
			n = N - 1
			dif_series_sum = round(n / 2 * (14 + (n - 1) * 4))
			return 3 + dif_series_sum
		else:
			return 3


class Solution:

	def differenceSeries(self, N):
		temp = 15
		li = [3, 10, 21, 36]
		while len(li) < N:
			li.append(li[-1] + temp + 4)
			temp = temp + 4
		if N == 0:
			return 1
		elif N <= 4:
			return li[N - 1]
		return li[-1]


class Solution:

	def differenceSeries(self, N):
		a = 3
		d = 7
		for i in range(N - 1):
			a += d
			d += 4
		return a


class Solution:

	def differenceSeries(self, N):
		a = N * (N + 1) + N ** 2
		return a


class Solution:

	def differenceSeries(self, N):
		self.s = 3
		self.m = 0
		for i in range(1, N + 1):
			self.m = self.s * i
			self.s += 2
		return self.m


class Solution:

	def differenceSeries(self, N):
		return 3 + (7 * (N - 1) + 2 * (N - 1) * (N - 2))


class Solution:

	def differenceSeries(self, N):
		t = 3 + (N - 1) * 2
		return N * t


class Solution:

	def differenceSeries(self, N):
		if N == 1:
			return 3
		else:
			return self.differenceSeries(N - 1) + 7 + 4 * (N - 2)


class Solution:

	def differenceSeries(self, N: int) -> int:
		return N * (2 * N + 1)


class Solution:

	def differenceSeries(self, N):
		K = 7
		d = [0] * (N + 1)
		d[0] = 3
		for i in range(1, N + 1):
			d[i] = d[i - 1] + K
			K += 4
		return d[N - 1]


class Solution:

	def differenceSeries(self, N):
		start = 3
		diff = 7
		if N == 1:
			return 3
		for i in range(2, N + 1):
			start = start + diff
			diff = diff + 4
		return start


class Solution:

	def differenceSeries(self, N):
		h = 7
		ss = 3
		for i in range(N - 1):
			ss += h
			h += 4
		return ss


class Solution:

	def differenceSeries(self, n):
		return n * (n + 1) + n * n


class Solution:

	def differenceSeries(self, N):
		n = N
		return n * (n + 1) + n ** 2


class Solution:

	def differenceSeries(self, n):
		k = pow(n, 2) * (2 * n + 1) // n
		return k


class Solution:

	def differenceSeries(self, N):
		diff = 7
		ans = 3
		for i in range(N - 1):
			ans += diff
			diff += 4
		return ans
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		ans = ob.differenceSeries(N)
		print(ans)


class Solution:

	def differenceSeries(self, N):
		return N * (N + 1) + N * N
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		ans = ob.differenceSeries(N)
		print(ans)


class Solution:

	def differenceSeries(self, N):
		su = 0
		a = 3
		if N != 1:
			for i in range(2, N + 1):
				a = a + 7 + 4 * (i - 2)
			return a
		else:
			return a
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		ans = ob.differenceSeries(N)
		print(ans)


class Solution:

	def differenceSeries(self, n):
		a = 3
		d = 7 + 2 * (n - 2)
		s = a + d * (n - 1)
		return s
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		ans = ob.differenceSeries(N)
		print(ans)


class Solution:

	def differenceSeries(self, N):
		a = 0
		d = 3
		for itr in range(N):
			a += d
			d += 4
		return a
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		ans = ob.differenceSeries(N)
		print(ans)


class Solution:

	def differenceSeries(self, N):
		s = (N - 1) * (14 + (N - 2) * 4) // 2
		return 3 + s
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		ans = ob.differenceSeries(N)
		print(ans)