1. Title Description
the rules for the number of columns are as follows: 1, 1, 2, 3, 5, 8, 13, 21, 34 ... the number of 30th digits is obtained by recursive algorithm .
2. Code implementation
1 PackageCom.wcy.october;2 3 /**4 * Date: October 23, 20165 * Title: The rules for the number of columns are as follows: 1, 1, 2, 3, 5, 8, 13, 21, 34 ... the 30th digit is the number of digits, which is realized by recursive algorithm. 6 */7 Public classRecursionTest1 {8 9 /**Ten * Solve with recursive algorithm One * @paramnumber of digits to solve A * @returnvalue of number of digits - */ - Public Static intGetResult (intNumber ) { the if(Number < 0) { - return0; - } - Else if(number = = 1 | | number = = 2) { + return1; -}Else { + returnGetResult (number-1) + GetResult (number-2); A } at } - - Public Static voidMain (string[] args) { - intresult = GetResult (9); - System.out.println (result); - } in}
Fibonacci Sequence of Recursive applet