diff options
author | Braxton Hall | 2022-10-30 16:12:31 +0000 |
---|---|---|
committer | GitHub | 2022-10-30 16:12:31 +0000 |
commit | 524d8c5e46ba22b068763e885850601464c25a56 (patch) | |
tree | 2790492c7e6c388a1fd90ca592f8e574a4616303 | |
parent | 59b31b060d7afffea217a65885bc89ba91b8a933 (diff) | |
parent | 9549fd1f14fef5b799f795d91f391df7d4c4826a (diff) |
Merge pull request #70 from j-james/main
Add Nim
-rw-r--r-- | entries/jj/nim/fib.nim | 17 | ||||
-rw-r--r-- | people.json | 11 |
2 files changed, 28 insertions, 0 deletions
diff --git a/entries/jj/nim/fib.nim b/entries/jj/nim/fib.nim new file mode 100644 index 0000000..a12f8e6 --- /dev/null +++ b/entries/jj/nim/fib.nim @@ -0,0 +1,17 @@ +func fib(n: Natural): Natural = + if n < 2: + return n + else: + return fib(n-1) + fib(n-2) + +func fib2(n: int, a = 0, b = 1): int = + return if n == 0: a else: fib2(n-1, b, a+b) + +iterator fib3: int = + var a = 0 + var b = 1 + while true: + yield a + swap a, b + b += a + diff --git a/people.json b/people.json index dd1b05c..297778c 100644 --- a/people.json +++ b/people.json @@ -553,5 +553,16 @@ "link": "./entries/kekerr/fib.ts" } ] + }, + { + "github": "j-james", + "name": "JJ", + "title": "BSc, UBC", + "entries": [ + { + "name": "nim", + "link": "./entries/jj/nim/fib.nim" + } + ] } ] |