-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.DS_Store | ||
/Manifest.toml | ||
*/Manifest.toml | ||
/dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |