The Fibonacci sequence, also known as the Golden series, refers to such a series: 1, 1, 2, 3, 5, 8,
13, 21 ,...... In mathematics, the Fibonacci series are defined in a recursive method as follows: f0 = 0, F1 = 1, FN = f (n-1) + f (n-2)
(N> = 2, nε N *) in modern physics, quasi-crystal structure, chemistry, and other fields, the Fibonacci series are directly applied. For this reason, American mathematics
From the 1960 s onwards, the journal of the Fibonacci series will be published to detail research results in this area.
Question: classical question: there is a rabbit. From the first 3rd months after birth, a rabbit is born every month. After the fourth month, a rabbit is born every month. If the Rabbit does not die, what is the total number of rabbits per month?
Program analysis: the rabbit rule is a sequence of numbers 1, 1, 2, 3, 5, 8, 13, 21 ....
Package WZS. arithmetics; // [Procedure 1] Title: classical problem: a rabbit has been born every month since 3rd months after birth, when the rabbit grows to the fourth month, another rabbit is born every month. // If the Rabbit does not die, how many rabbits are there every month? // 1. program analysis: the rabbit rule is a sequence of numbers 1, 1, 2, 3, 5, 8, 13, 21 .... public class test_wzs1 {public static void main (string [] ARGs) {test_wzs1 test_wzs1 = new test_wzs1 (); // display the number of rabbits in the first 20 months for (INT I = 0; I <20; I ++) {system. out. println ("nth" + (I + 1) + "months total Rabbit" + test_wzs1.f (I + 1) + "pair. ") ;}}/**** returns the number of rabbits per month * @ Param X number of months * @ return returns the number of rabbits in the current month */Public int F (int x) {If (x = 1 | x = 2) {return 1 ;}else {return f (x-1) + f (x-2 );}}}