javascript fibonacci series
// number fibonnaci to array format
function fibonacci(nums) {
let fib = [0, 1];
let data = [];
for(let i = 2; i <= nums; i++) {
fib[i] = fib[i - 1] + fib[i - 2];
data.push(fib[i]);
}
return data;
}const fibo = (n, memo = {}) => memo[n] || (n <= 2 ? 1 : (memo[n] = fibo(n - 1, memo) + fibo(n - 2, memo)));
// Examples
fibo(6); // 8function fibonacci(num){
var num1=0;
var num2=1;
var sum;
var i=0;
for (i = 0; i < num; i++){
sum=num1+num2;
num1=num2;
num2=sum;
}
return num2;
}
Also in JavaScript:
- bootstrap show modal jquery
- save a dict to json python
- react create pillbox for each chunk of array
- how to make graphql request in axios
- electron getPath
- stackable in amcharts 3
- clone an object javascript
- js rounding
- react-native-screens
- replace each string by another string javascript
- jquery wait for target to load
- get year javascript copyright
- js hangman with repeated characters
- jquery siblings
- how to wait for a function to finish in javascript
- sortable order jquery
- glitch node version
- js for of loop
- build react app
- run javascript sublime text 3
- kubectl get pod by node
- assign array to another array javascript
- contact form7 404 wp-json feedback
- javascript get intersection of two arrays