Skip to content

Commit

Permalink
Add Fibonacci
Browse files Browse the repository at this point in the history
  • Loading branch information
yuehhua committed Apr 13, 2020
1 parent 8104117 commit d3fe076
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.DS_Store
/Manifest.toml
*/Manifest.toml
/dev/
13 changes: 13 additions & 0 deletions Fibonacci/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name = "Fibonacci"
uuid = "59099692-28a4-44f4-8929-e168c0ee2466"
authors = ["Yueh-Hua Tu <[email protected]>"]
version = "0.1.0"

[compat]
julia = "1.4"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
33 changes: 33 additions & 0 deletions Fibonacci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 費氏數列

[費氏數列](https://www.wikiwand.com/zh-hant/%E6%96%90%E6%B3%A2%E9%82%A3%E5%A5%91%E6%95%B0%E5%88%97),又稱黃金分割數列,是自然界中非常常見的數列。它是由以下遞迴式所定義:

![](https://i.imgur.com/7ggYrnU.png)

產生以下數列:

```
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
```

請根據遞迴撰寫產生費氏數列的程式,輸入為數列的序數,輸出為費氏數列的數值。

## 測試

```julia
@test fibonacci(0) .== 0
@test fibonacci(1) .== 1
@test fibonacci(2) .== 1
@test fibonacci(4) .== 3
```

### 測試資料

```julia
fibonacci(0)
fibonacci(1)
fibonacci(2)
fibonacci(4)
fibonacci(10)
fibonacci(50)
```
9 changes: 9 additions & 0 deletions Fibonacci/src/Fibonacci.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Fibonacci

src = []

for s = src
include("$(s).jl")
end

end # module
10 changes: 10 additions & 0 deletions Fibonacci/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Fibonacci
using Test

tests = []

@testset "Fibonacci.jl" begin
for t in tests
include("$(t).jl")
end
end

0 comments on commit d3fe076

Please sign in to comment.