Knowee
Questions
Features
Study Tools

Everyone knows about fibonacci series: 1, 1, 2, 3, 5, 8, 13, 21, 34,..... . All you have to do is print the Nth fibonacci number.InputThe first line of input contains T - number of test cases. It is followed by T lines, each line containing a single integer - N.OutputFor each test case, print the Nth Fibonacci number, separated by new line. Since the number can be very large, print result % 1000000007.Constraints10 points1 <= T <= 10000 <= N <= 2030 points1 <= T <= 10000 <= N <= 10360 points1 <= T <= 10000 <= N <= 107100 points1 <= T <= 10000 <= N <= 1018ExampleInput7012710010000001000000000Output11221782204094534400663999999994

Question

Everyone knows about fibonacci series: 1, 1, 2, 3, 5, 8, 13, 21, 34,..... . All you have to do is print the Nth fibonacci number.InputThe first line of input contains T - number of test cases. It is followed by T lines, each line containing a single integer - N.OutputFor each test case, print the Nth Fibonacci number, separated by new line. Since the number can be very large, print result % 1000000007.Constraints10 points1 <= T <= 10000 <= N <= 2030 points1 <= T <= 10000 <= N <= 10360 points1 <= T <= 10000 <= N <= 107100 points1 <= T <= 10000 <= N <= 1018ExampleInput7012710010000001000000000Output11221782204094534400663999999994

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

This problem is about finding the Nth Fibonacci number modulo 1000000007. The Fibonacci sequence is defined as F(0) = 0, F(1) = 1, and F(n) = F(n-1) + F(n-2) for n > 1.

Here is a Python solution using matrix exponentiation, which allows us to compute the Nth Fibonacci number in O(log N) time. This is necessary because N can be as large as 10^18.

MOD = 1000000007

def multiply

Similar Questions

Create a program that generates and prints the Fibonacci series up to a specified number 'N'. The Fibonacci series is a sequence of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. Your program should take an integer input 'N' and display the Fibonacci series up to the Nth term using a while loop.Fibonacci series: 0, 1, 1, 2, 3, 5, 8,... Note: This question is one of the most asked questions in placements.Input format :The input consists of a positive integer N.Output format :The output displays the Fibonacci series up to the Nth term separated by space.

Input FormatThe first line of input contains T - the number of test cases. It's followed by T lines, each line contains 2 numbers N and P, separated by space.Output FormatFor each test case, print the value of N % P, separated by a new line.Constraints20 points1 <= T <= 1001 <= N <= 10181 <= P <= 10880 points1 <= T <= 1001 <= N <= 10100001 <= P <= 1015ExampleInput45 24 101085377843 817659438290826691135830692772803 95972011Output142242058460316167

Print Fibonacci numbers till nTake an input n and print Fibonacci numbers till n.Input FormatInteger input nConstraints0=n<=pow(10, 19)Output FormatFibonacci numbers till n.Sample input1Sample output0, 1, 1.ExplanationSample Input 01Sample Output 00, 1, 1.Sample Input 15Sample Output 10, 1, 1, 2, 3, 5.Sample Input 20Sample Output 20.Sample Input 34Sample Output 30, 1, 1, 2, 3.Sample Input 4100Sample Output 40, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89.Note:Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement.LimitsTime Limit: 5.0 sec(s) for each input fileMemory Limit: 256 MBSource Limit: 1024 KBScoringScore is assigned if any testcase passes

Given an integer N, find the maximum sum that you can get from the following series: 1*2 - 2*3 + 3*4 - 4*5 .... K*(K+1), where K<=N.Input FormatThe first line of input contains T - the number of test cases. It is followed by T lines, each contains a single integer N.Output FormatFor each test case, print the result, separated by a newline.Constraints30 points1 <= T <= 1001 <= N <= 10070 points1 <= T <= 1051 <= N <= 109ExampleInput235Output818

Generate the Fibonacci sequence up to the 10th term and calculate the value of the 10th term.

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.