Given a series with starting 6 members of the series. Given an integer n find the nth term of this series modulo 10^{9}+7.
Series: 7, 15, 32, 67, 138, 281, ............
Example 1:
Input: n = 2
Output: 15
Explaination: The value is given in 
the series in question.
Your Task:
You do not need to read input or print anything.Your task is to complete the function nthTerm() which takes n as input parameter and returns the value of the nth term modulo 10^{9}+7.
Expected Time Complexity: O(n)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ n ≤ 120

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:
    def nthTerm(self, n):
        # code here

Solutions:
class Solution:

	def nthTerm(self, n):
		if n == 1:
			return 7
		s = 7
		m = 10 ** 9 + 7
		for i in range(2, n + 1):
			s = (s * 2 + (i - 1)) % m
		return s


class Solution:

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


class Solution:

	def nthTerm(self, n):
		MOD = 1000000007
		nthterm = 7
		for i in range(2, n + 1):
			nthterm = nthterm * 2 + i - 1
		return nthterm % MOD


class Solution:

	def nthTerm(self, n):
		nxt_num = 7
		if n == 1:
			return 7
		else:
			for i in range(2, n + 1):
				nxt_num = nxt_num * 2 + (i - 1)
			return nxt_num % (10 ** 9 + 7)


class Solution:

	def nthTerm(self, n):
		return (9 * 2 ** (n - 1) - n - 1) % 1000000007


class Solution:

	def nthTerm(self, n):
		if n == 1:
			return 7
		return (self.nthTerm(n - 1) * 2 + n - 1) % 1000000007


class Solution:

	def nthTerm(self, n):
		ans = 7
		for i in range(1, n):
			ans = ans * 2 + i
		return ans % 1000000007


class Solution:

	def nthTerm(self, n: int) -> int:
		(a, b) = (7, 15)
		for _ in range(n - 1):
			(a, b) = (b, b + 2 * (b - a) + 1)
		return a % 1000000007


class Solution:

	def nthTerm(self, n):
		a = 7
		for i in range(1, n):
			b = a * 2 + i
			a = b % 1000000007
		return a


class Solution:

	def nthTerm(self, n):
		ans = 7
		m = 1000000000.0 + 7
		for i in range(1, n):
			ans = ans * 2 % m
			ans += i
		return int(ans)


class Solution:

	def nthTerm(self, n):
		x = [7, 15]
		for i in range(2, n + 1):
			x.append(x[-1] * 2 + i)
		return x[n - 1] % 1000000007


class Solution:

	def nthTerm(self, n):
		if n == 1:
			return 7
		if n == 2:
			return 15
		k = 15
		s = 8
		n = n - 2
		c = 9
		while n > 0:
			s = s + c
			k = k + s
			c = c * 2
			n = n - 1
		return k % (10 ** 9 + 7)


class Solution:

	def nthTerm(self, n):
		return (7 + 9 * (pow(2, n - 1) - 1) - (n - 1)) % 1000000007


class Solution:

	def nthTerm(self, n):
		if n == 1:
			return 7
		else:
			return (2 * self.nthTerm(n - 1) + (n - 1)) % (10 ** 9 + 7)