From 1348bd5e6af0ee8bbc6beb8bcd25a461b8101b69 Mon Sep 17 00:00:00 2001 From: Vinicius Date: Wed, 2 Nov 2022 18:42:16 -0200 Subject: [PATCH] feat(fibonacci): cria funcao de fibonacci --- 04-fibonacci/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..0131f9a 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,11 @@ export function fibonacci(value) { // implementar logica aqui - -} \ No newline at end of file + let f = []; + f[0] = 0; + f[1] = 1; + for (n = 2; n <= value; n++) { + f[n] = f[n - 1] + f[n - 2]; + } + + return f[value]; +} -- 2.34.1