Hard Fibonacii...... Today we eill learn to find the n'th fibonacci number after %M. Since it is vey dfficult to store the large Fibonacci number,because the rate is exponention. But there is a unique properties of Fibonacci series by which it is periodic n nature.... Lets see an samll example m = 2 or m = 3. Take a detailed look at this table. Do you see? Both these sequences are periodic! For m = 2, the period is 011 and has length 3, while for m = 3 the period is 01120221 and has length 8. Therefore, to compute, say, F2015 mod 3 we just need to find the remainder of 2015 when divided by 8. Since 2015 = 251·8 + 7, we conclude that F2015 mod 3 = F7 mod 3 = 1. This is true in general: for any integer m ≥ 2, the sequence Fn mod m is periodic. The period always...
Posts
Showing posts with the label Fibonacci Series
- Get link
- X
- Other Apps
FIBONACCI....Series Let's see an interesting example of Fibonacci series by solving this interesting problem. Last digit of Fibonacci series after performing K task You are given a number N and a number K you have to print the last digit of the Fibonacci series after recursively generating the set of S such that S ={F k ,F 2*k …….} i.e the set S should only contain the K th index Fibonacci number. Kindly see the explanation for better understanding Explanation: consider : N=10 and K=3; The Fibonacci series is: 0 1 1 2 3 5 8 13 21 34 //1 based indexing since K=3 S={1,5,21} S={21} There fore the output is 1 //The last digit of that number Examples: The First number is N and then K. Input :10 3 Output :1 see the explanation part. Approach 1.Brute Force We can generate the Fibonacci series and store in the array and then apply nested loop to search for the last K Fibonacci number and...