diff options
author | Braxton Hall | 2022-10-30 18:31:24 +0000 |
---|---|---|
committer | GitHub | 2022-10-30 18:31:24 +0000 |
commit | 2b6cc41790836e7e1ecc9b444e16d0f408f0b976 (patch) | |
tree | 74f1a488168d5ac54a1f713b98421c43ac97b51a | |
parent | 5600e28c47e4e6672c8e93a35aec0957236e1356 (diff) | |
parent | 524d8c5e46ba22b068763e885850601464c25a56 (diff) |
Merge branch 'main' into main
-rw-r--r-- | entries/jj/nim/fib.nim | 17 | ||||
-rw-r--r-- | people.json | 33 |
2 files changed, 39 insertions, 11 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 de7ea5b..0d42b90 100644 --- a/people.json +++ b/people.json @@ -554,15 +554,26 @@ } ] }, - { - "github": "cc-21", - "name": "Madonna H", - "title": "lazy", - "entries": [ - { - "name": "a buggy fib", - "link": "./entries/cc-21/fib.java" - } - ] - } + { + "github": "cc-21", + "name": "Madonna H", + "title": "lazy", + "entries": [ + { + "name": "a buggy fib", + "link": "./entries/cc-21/fib.java" + } + ] + }, + { + "github": "j-james", + "name": "JJ", + "title": "BSc, UBC", + "entries": [ + { + "name": "nim", + "link": "./entries/jj/nim/fib.nim" + } + ] + } ] |