Fibonacci系列的第n个术语,用于海量数据输入(无递归或循环) [英] nth term for Fibonacci series for enormous data input(Without Recursion or loop)

查看:138
本文介绍了Fibonacci系列的第n个术语,用于海量数据输入(无递归或循环)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

创建一个与楼梯问题有关的程序,即您有 n 个楼梯,玩家可以使用楼梯一个一个地爬上楼梯,也可以跳过一个楼梯...

I was creating a program which is related to the stair problem, i.e you have n stairs and the player can climb on the stairs using them one by one or skipping one ...

现在要解决此问题,我需要为 n 的斐波那契第 n 个( n +1)项楼梯,但问题是我的输入范围是1≤ n ≤1000000。

Now to solve this problem I needed nth (n+1)th term for the Fibonacci for n number of stairs, but the problem is my input range is 1 ≤ n ≤ 1000000.

并且 n的值更大如果我使用基于循环的方法或递归来计算斐波那契,则该方法将花费大量时间和空间。我没有。

And for that much greater value of n if I use the loop based method or recursion to calculate the Fibonacci the method takes very much time and space. That I do not have.

所以请您告诉我Java或C语言中的一些方法,以正确的输出值处理该范围内的斐波那契数列?

So please can you tell me some method in the Java or C to handle Fibonacci series up to that range with correct output?

注意:请不要使用任何具有递归或循环的解决方案。

Note: Please I do not need any solution which has recursion or loop.

推荐答案

查看以下页面,可能会有所帮助: https:// www .nayuki.io / page / fast-fibonacci-algorithms

Look at the following page, maybe it will help: https://www.nayuki.io/page/fast-fibonacci-algorithms

对我来说,他们的Java示例成功计算出第1000000个斐波那契数。它是208988位数字。

For me their Java example managed to calculate 1000000th Fibonacci number. It is 208988 digits long.

这篇关于Fibonacci系列的第n个术语,用于海量数据输入(无递归或循环)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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