Import Java. util. created;/*** created by Administrator on 14-5-13. * The improved method for calculating the Fibonacci sequence. Using parameters, the test run time will multiply and decrease the test data n = 40 * the essence of tail recursion is to cache the results of a single computation, passed to the next call, which is equivalent to automatic accumulation. * Tail recursion is a programming technique. A recursive function is a function that calls its own function. * If the result returned by a recursive function is always directly returned, it is called tail recursion. * Recursive functions at the end can be used to convert algorithms into function programming languages. * from the compiler perspective, algorithms can easily be optimized into common loops. * This is because from the computer fundamentals, all cycles are implemented by repeatedly moving to the beginning of the Code. * If there is tail delivery, you only need to stack one stack, because the computer only needs to change the function parameters and then call them again. * Tail recursion is mainly used to optimize tail recursion. For example, in scheme, it is specified that tail recursion must be optimized. * The tail recursion function is very dependent on the specific implementation. */Public class fib1 {public static void main (string [] ARGs) {long starttime = system. currenttimemillis (); // get start time int number = 0; system. out. println ("please give the number:"); commandid = new partition (system. in); string STR = response. nextline (); try {number = integer. parseint (STR);} catch (numberformatexception e) {system. out. println ("incorrect input");} system. out. println (FAC (number, 1, 1); long endtime = system. currenttimemillis (); // obtain the end time system. out. println ("program running time:" + (endtime-starttime) + "Ms");} public static int FAC (INT temp, int F1, int F2) {If (temp <2) {return F1;} else {system. out. println ("FAC (" + (temp-1) + ''+ F2 + ',' + (F1 + F2) +") "); Return FAC (temp-1, F2, f2 + F1 );}}}