Skip to content

Commit

Permalink
style: simplify fib_iterative (#188)
Browse files Browse the repository at this point in the history
* tests: add missing test case for `fib_iterative`

* style: remove redundant brach in `fib_iterative`
  • Loading branch information
vil02 authored Oct 2, 2023
1 parent 4da6bc6 commit 40586f4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 0 additions & 2 deletions src/math/fibonacci.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ function fib_iterative(n::Int)
throw(DomainError("n is negative"))
elseif n == 1
return [0]
elseif n == 2
return [0, 1]
else
result = [0, 1]
a, b = 0, 1
Expand Down
1 change: 1 addition & 0 deletions test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ using TheAlgorithms.Math
@test fib_recursive_memo(6) == [0, 1, 1, 2, 3, 5]
@test_throws DomainError fib_recursive_memo(-1)
@test fib_iterative(1) == [0]
@test fib_iterative(2) == [0, 1]
@test fib_iterative(6) == [0, 1, 1, 2, 3, 5]
@test_throws DomainError fib_iterative(-1)
end
Expand Down

0 comments on commit 40586f4

Please sign in to comment.