aboutsummaryrefslogtreecommitdiff
path: root/entries
diff options
context:
space:
mode:
authorBraxton Hall2022-10-27 18:17:46 +0000
committerGitHub2022-10-27 18:17:46 +0000
commiteea4d18a2ef4cfe4e5f4d4a302b6ef452dec18b7 (patch)
treef0a34eef5942d733526cec026e4d7bee15d836c5 /entries
parentc2cde6bb9c1a43a69a276a20ad083d88b6fa0693 (diff)
parentac2833eb3c3e3a7c75709d992bfd9115254412de (diff)
Merge pull request #57 from kekerr/main
Katharine's contribution with a basic fib
Diffstat (limited to 'entries')
-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();
+}