Matrix Exponentiation
Submissions: 552   Accuracy:

19.14%

  Difficulty: Medium   Marks: 4

Given an equation of the form F(n) = F(n-2) + F(n-3) where F(0) = 1, F(1) = 0, F(2) = 1 , the task is to find the nth term of this sequence.

Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer N.

Output:
For each test case in a new line print the nth term of the sequence mod 10^9+7.

Constraints:
1<=T<=100
1<=N<=10^18+5

Example:
Input:

2
3
6

Output:
1
2

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: Shubham Joshi 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.