Java | Study Notes | Fibonacci series

Fibonacci sequence
time limit: 1.0s
memory limit: 256.0MB
Keywords: Getting modulo the number of columns the problem
described in the Fibonacci recursion formulas as: Fn = Fn-1 + Fn -2, where F1 = F2 = 1. When n is relatively large, Fn is very great, and now we want to know, Fn is divided by the number 10007 is.
Input Format contains an integer n.
Output format output one line containing an integer representing the Fn remainder of the division of 10007.

Description: In this problem, the answer is to require Fn is divided by 10007, so we can figure this out as long as the remainder can be, without the need to calculate the exact value of Fn, then the result is calculated by dividing the number 10007 to take over direct calculation the remainder often than first calculate the original number and then take the remainder simple.
Input Sample
10
Sample output
55
Sample Input
22
sample output
7704
data size and Conventions 1 <= n <= 1,000,000.
Reference Code:

Here Insert Picture DescriptionHere Insert Picture Description
Here Insert Picture Description
Summary:
The first way is to introduce the function of a fib:
For this recursive function fib, the most important thing is to seize the export
method and if you do not use the array can also be used to change the value.
Note
System.out.print ();
System.out.println (); difference

Released three original articles · won praise 0 · Views 25

Guess you like

Origin blog.csdn.net/weixin_44908812/article/details/104147899