aboutsummaryrefslogtreecommitdiff
path: root/entries/kekerr/fib.ts
diff options
context:
space:
mode:
authorBraxton Hall2022-10-27 20:54:39 +0000
committerGitHub2022-10-27 20:54:39 +0000
commit3d3a66b5b4c23c5acd1dbde12957191e224849b1 (patch)
treed36a6b9387d69a49f57087532a0192ec6356b84c /entries/kekerr/fib.ts
parent0c016d787b18f2e0ccba2892067e6ab0c4bb30ad (diff)
parent0c3a8d355afe70a3ba593fc3f1ead665abf5bb09 (diff)
Merge branch 'main' into main
Diffstat (limited to 'entries/kekerr/fib.ts')
-rw-r--r--entries/kekerr/fib.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/entries/kekerr/fib.ts b/entries/kekerr/fib.ts
new file mode 100644
index 0000000..cc42fcf
--- /dev/null
+++ b/entries/kekerr/fib.ts
@@ -0,0 +1,16 @@
+function fibonacci(n: number): string {
+ if (n <= 0) {
+ return "Surely that's a mistake! We can't give you anything interesting!";
+ }
+
+ if (n == 1) {
+ return "This one's easy: [1]";
+ }
+
+ const seq = [1, 1];
+ for(let i = 2; i < n; i++) {
+ seq.push(seq[i-1] + seq[i-2]);
+ }
+
+ return "Fibonacci this: " + seq.toString();
+}