且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Fibonacci序列(JS) - 偶数之和

更新时间:2021-07-29 23:26:17

让我打破这个:

在控制台上,您将看到您执行的任何表达式的结果。如果执行一段代码,您将看到在块中执行的最后一个表达式。与此直观相反,在这种情况下,它是 current = next 的结果,因为if语句不会在上一次通过for循环运行。

On the console, you will see the result of any expression you execute. If you execute a block of code you will see the last expression you executed in the block. Counter intuitively, in this case it is the result of current = next because the if statement is not run on your last time through the for loop.

第100个斐波纳契数是354224848179261915075.但是当你的数字超过某一点并开始时,JavaScript会失去精确度假设你的数字的所有下半部分都是零。有关移动详情,请参阅此问题:为什么JavaScript会考虑354224848179262000000和354224848179261915075是平等的吗?

The hundredth Fibonacci number is 354224848179261915075. JavaScript however loses precision as your numbers get past a certain point and starts assuming that all of the lower part of your number is zeros. See this question for move details: Why does JavaScript think 354224848179262000000 and 354224848179261915075 are equal?.