Little Shino and the Fibonacci series
Practice
3.9 (29 votes)
Mathematics
Easy Medium
Mathematics
Mathamatics
Problem
91% Success 6349 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Little Shino loves to play with numbers. She just came to know about Fibonacci Series.
Fibonacci Series is a series of number such that

\(Fib(1) = 0\)
\(Fib(2) = 1\)
\(Fib(x) = Fib(x-1) + Fib(x-2)\;where\;2 \lt x\)

Soon Little Shino realized that Fibonacci series grows very fast. So she just wants the sum of last 4 digits of the \(Fib(x)\) where \(l \le x \le r\) (mod \(10^9 + 7\)) . Can you help her.

Input:
First line of each test case contains one integer, T, number of test cases.
Each test case contains two integer, l and r.

Output:
Print the sum of last 4 digits of the \(Fib(x)\) where \(l \le x \le r\) (mod \(10^9 + 7\)).

Constraints:
\(1 \le T \le 10^5\)
\(1 \le l \le r \le 10^{18}\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
15 votes
Tags:
MathematicsEasy-MediumOpenApprovedGreedy algorithmMathamatics
Points:30
5 votes
Tags:
MathematicsBasic MathMath
Points:30
13 votes
Tags:
Basic MathEasy-MediumMathematicsMathematics