Perrin Numbers Modulo
The sequence obeys Q(0)=3, Q(1)=0, Q(2)=2 and Q(n)=Q(n−2)+Q(n−3). Print term N modulo 109+7.
Input: one integer N.
Output: term N mod 109+7.
Constraints:
- 0 ≤ N ≤ 1018
Sample Tests
Input 1
5
Output 1
5
Input 2
0
Output 2
3
Discussion (opens after you solve — no spoilers before)
No comments yet.