fibonnacci的上限 [英] Upper limits for fibonnacci

查看:164
本文介绍了fibonnacci的上限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读关于斐波纳西的DP版本。

在Sedgewick我看到:

int [] T = new int [47]; 用于存储先前的计算。在其他地方,我看到斐波纳契的最大输入应该小于 92

我不清楚这些数字是如何出现的?我知道它与溢出和 int 的大小有关,但我不清楚我们如何最终得到这些限制。

有什么帮助吗? / p>

I was reading about the DP version of fibonnaci.
In Sedgewick I saw:
int[] T = new int[47]; for storage of the previous calculations. Elsewhere I saw that the max input for fibonacci should be less than 92.
It is not clear to me how does these numbers come up? I understand that it has to do with overflow and size of int but I am not clear how we end up with these limits.
Any help?

推荐答案

好吧,斐波纳契系列以1.618(黄金比率)的比例增长(大约)指数。

Well, the fibonacci series grows (approximately) exponentially with a ratio of 1.618 (the golden ratio).

如果您使用 Integer.MAX_VALUE 的日志基数1.618,它将告诉您大约在溢出之前可以进行的迭代次数。 ..

If you take the log base 1.618 of Integer.MAX_VALUE it will therefore tell you approximately how many iterations you can go before overflowing....

或者,您只需通过计算就可以凭经验确定何时溢出....

Alternatively, you can determine empirically when it overflows just by doing the calculations....

这篇关于fibonnacci的上限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆