P16293 [GeeksforGeeks] Sequence fun5018
普及-
题目描述

You have a sequence 2,5,16,65,........Given an integer n as input. You have to find the value at the nth position in the sequence.

Example 1:
Input: n = 4
Output: 65
Example 2:
Input: n = 10
Output: 9864101

Your Task:
You don't need to read or print anything, Your task is to complete the function NthTerm() which takes n as input parameter and returns value at nth position of the given sequence modulo 10^{9} + 7.

Expected Time Complexity: O(n)
Expected Space Complexity: O(1)

Constraints:
1 <= n <= 10^{4}

输入格式

见题面

输出格式

见题面

样例输入
n = 4
样例输出
65