Created
October 18, 2021 22:55
-
-
Save lfelguetac/639afbdf242b1cae9bea871f21e632cb to your computer and use it in GitHub Desktop.
secuencia fibonacci
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getFibonnaci = (n: number) => { | |
let fibonnaci = [0, 1]; | |
let large = fibonnaci.length; | |
while (true) { | |
let nextValue = fibonnaci[large-2] + fibonnaci[large-1] | |
if (nextValue > n) break | |
fibonnaci.push(nextValue); | |
large = fibonnaci.length; | |
} | |
return fibonnaci; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mejor idea:
const fibo = getFibonnaci(100);
.... 0, 1, 1, 2, 3,
5, 8, 13, 21, 34,
55, 89