From 95d780b52a5c90f04e2bd8bc7af171b6b2618bd9 Mon Sep 17 00:00:00 2001 From: Hazem Elsayed Date: Sun, 31 Aug 2025 12:25:38 +0300 Subject: [PATCH] fix export and declare types --- src/fib.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/fib.ts b/src/fib.ts index 8dc8ddd..6247674 100644 --- a/src/fib.ts +++ b/src/fib.ts @@ -1,12 +1,16 @@ -// util function that computes the fibonacci numbers -module.exports = function fibonacci(n) { +/** + * @param n The index of the Fibonacci number to compute. + * @returns The nth Fibonacci number, or -1 for negative input. + */ +export function fibonacci(n: number): number { if (n < 0) { return -1; - } else if (n == 0) { + } + if (n === 0) { return 0; - } else if (n == 1) { + } + if (n === 1) { return 1; } - return fibonacci(n - 1) + fibonacci(n - 2); -}; +} \ No newline at end of file