Skip to content

Commit 281f491

Browse files
authored
use identities for 0(0th) fib convention (#1001)
1 parent 8bb0d16 commit 281f491

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/boost/math/special_functions/fibonacci.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ inline BOOST_CXX14_CONSTEXPR T unchecked_fibonacci(unsigned long long n) noexcep
3232
if (n <= 2) return n == 0 ? 0 : 1;
3333
/*
3434
* This is based on the following identities by Dijkstra:
35-
* F(2*n) = F(n)^2 + F(n+1)^2
36-
* F(2*n+1) = (2 * F(n) + F(n+1)) * F(n+1)
35+
* F(2*n-1) = F(n-1)^2 + F(n)^2
36+
* F(2*n) = (2*F(n-1) + F(n)) * F(n)
3737
* The implementation is iterative and is unrolled version of trivial recursive implementation.
3838
*/
3939
unsigned long long mask = 1;

0 commit comments

Comments
 (0)