Skip to content

Commit

Permalink
use identities for 0(0th) fib convention (#1001)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanelandt authored Jul 25, 2023
1 parent 8bb0d16 commit 281f491
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/boost/math/special_functions/fibonacci.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ inline BOOST_CXX14_CONSTEXPR T unchecked_fibonacci(unsigned long long n) noexcep
if (n <= 2) return n == 0 ? 0 : 1;
/*
* This is based on the following identities by Dijkstra:
* F(2*n) = F(n)^2 + F(n+1)^2
* F(2*n+1) = (2 * F(n) + F(n+1)) * F(n+1)
* F(2*n-1) = F(n-1)^2 + F(n)^2
* F(2*n) = (2*F(n-1) + F(n)) * F(n)
* The implementation is iterative and is unrolled version of trivial recursive implementation.
*/
unsigned long long mask = 1;
Expand Down

0 comments on commit 281f491

Please sign in to comment.