Java - 斐波那契数列 - recursiveWrite recursive Java code to compute terms of the Fibonacci sequence.Use this to compute the 5th,10th,40th,60th and 90th terms.我用基本的recursive写了一下,可是到40项以后就算不出来了.如果仅
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/29 21:46:09
![Java - 斐波那契数列 - recursiveWrite recursive Java code to compute terms of the Fibonacci sequence.Use this to compute the 5th,10th,40th,60th and 90th terms.我用基本的recursive写了一下,可是到40项以后就算不出来了.如果仅](/uploads/image/z/12299746-58-6.jpg?t=Java+-+%E6%96%90%E6%B3%A2%E9%82%A3%E5%A5%91%E6%95%B0%E5%88%97+-+recursiveWrite+recursive+Java+code+to+compute+terms+of+the+Fibonacci+sequence.Use+this+to+compute+the+5th%2C10th%2C40th%2C60th+and+90th+terms.%E6%88%91%E7%94%A8%E5%9F%BA%E6%9C%AC%E7%9A%84recursive%E5%86%99%E4%BA%86%E4%B8%80%E4%B8%8B%2C%E5%8F%AF%E6%98%AF%E5%88%B040%E9%A1%B9%E4%BB%A5%E5%90%8E%E5%B0%B1%E7%AE%97%E4%B8%8D%E5%87%BA%E6%9D%A5%E4%BA%86.%E5%A6%82%E6%9E%9C%E4%BB%85)
Java - 斐波那契数列 - recursiveWrite recursive Java code to compute terms of the Fibonacci sequence.Use this to compute the 5th,10th,40th,60th and 90th terms.我用基本的recursive写了一下,可是到40项以后就算不出来了.如果仅
Java - 斐波那契数列 - recursive
Write recursive Java code to compute terms of the Fibonacci sequence.Use this to compute the 5th,10th,40th,60th and 90th terms.我用基本的recursive写了一下,可是到40项以后就算不出来了.如果仅用加法算最近的两项(释放其他内存),又不算是recursive,求一种既是recursive又可以用普通的单核电脑算出来的java code...
这种recursive:
public static long fib(long n) {
if (n
Java - 斐波那契数列 - recursiveWrite recursive Java code to compute terms of the Fibonacci sequence.Use this to compute the 5th,10th,40th,60th and 90th terms.我用基本的recursive写了一下,可是到40项以后就算不出来了.如果仅
用散列表加了个缓存,可以算到long最大值存不下了吧
import java.util.Hashtable;
public class Test {
public static long fib(int n,Hashtable t) {
if (n