Created
July 10, 2022 11:50
-
-
Save faizul14/454f699f613f57ffb6021c25f4de23a0 to your computer and use it in GitHub Desktop.
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
function fabionanci(n){ | |
const dataFabionanci = []; | |
for (let i = 0; i <= n; i++){ | |
if(i < 2){ | |
dataFabionanci.push(i); | |
}else{ | |
dataFabionanci.push(dataFabionanci[i-1] + dataFabionanci [i - 2]); | |
} | |
} | |
for(let i = 0; i <= dataFabionanci.length; i++){ | |
console.log(dataFabionanci[i]); | |
} | |
} | |
fabionanci(20); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment