Skip to content

Commit

Permalink
Merge pull request #4171 from hardliner66/patch-1
Browse files Browse the repository at this point in the history
Fibonacci should only be calculated for values bigger than 2.
  • Loading branch information
DmitryOlshansky committed May 8, 2016
2 parents 0117797 + 72dd35b commit e280cb6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions std/functional.d
Original file line number Diff line number Diff line change
Expand Up @@ -1063,9 +1063,9 @@ unittest
{
ulong fib(ulong n)
{
return n < 2 ? 1 : memoize!fib(n - 2) + memoize!fib(n - 1);
return n < 2 ? n : memoize!fib(n - 2) + memoize!fib(n - 1);
}
assert(fib(10) == 89);
assert(fib(10) == 55);
}

/**
Expand Down

0 comments on commit e280cb6

Please sign in to comment.