From 460aaa31a61696c01af80402754c66fb732f7a3b Mon Sep 17 00:00:00 2001 From: braxtonhall Date: Wed, 26 Oct 2022 10:24:40 -0700 Subject: Add Kevin Dhir --- entries/kevindhir/ts/fib.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 entries/kevindhir/ts/fib.ts (limited to 'entries/kevindhir/ts/fib.ts') diff --git a/entries/kevindhir/ts/fib.ts b/entries/kevindhir/ts/fib.ts new file mode 100644 index 0000000..f126a8b --- /dev/null +++ b/entries/kevindhir/ts/fib.ts @@ -0,0 +1,8 @@ +let memo = {1: 1}; + +function fib(n: number): number { + if(n <= 0) return 0; + if(memo[n]) return memo[n]; + memo[n] = fib(n-1) + fib(n-2); + return memo[n]; +}; -- cgit v1.2.3-70-g09d2