Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

fibonacci sequence

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
Comment

fibonacci sequence

function _fib(number) {
    if (number === 0 || number === 1) {
        return number;
    } else {
        return _fib(number - 1) + _fib(number - 2)
    }
}
Comment

fibonacci sequence

//x is the index number in the fibonnacci sequence. 
//The function will return that index's fibonacci value
function fib(x) {
    let a = 0;
    let b = 1;
    for (var i = 0; i < x-1; i++) {
        let c = b;
        b += a;
        a = c;
    }
    return b;
}
Comment

the fibonacci sequence

int fabseq(int nth){
        if (nth == 1 || nth == 2){
            return 1;
        }
        int equ = (1/sqrt(5))*pow(((1+sqrt(5))/2), nth)-(1/sqrt(5))*pow((1-sqrt(5))/2, nth);
        return equ;
}
Comment

Fibonacci sequence

function myFib(n) {
    if (isNaN(n) || Math.floor(n) !== n)
        return "Not an integer value!";
    if (n === 0 || n === 1)
        return 3;
    else
        return myFib(n - 1) + myFib(n - 2);
}

console.log(myFib(5));


Comment

Fibonacci Sequence

nterms = int(input())

x, y, z = 1, 1, 0

if nterms == 1:
   print(x)
else:
   while z < nterms:
       print(x, end=" ")
       nth = x + y
       x = y
       y = nth
       z += 1
Comment

PREVIOUS NEXT
Code Example
Python :: class method in python 
Python :: longest palindromic substring using dp 
Python :: when iterating through a pandas dataframe using index, is the index +1 able to be compared 
Python :: python how to switch between true and false 
Python :: python online compiler 
Python :: shape of variable python 
Python :: color reverse 
Python :: python code variable declaration 
Python :: typecasting python 
Python :: python calculator 
Python :: merge sort function 
Python :: how to find the last element of list in python 
Python :: convert date to string in python 
Python :: plotly change legend name 
Python :: what does abs do in python 
Python :: string comparison in python 
Python :: python 2 
Python :: data encapsulation in python 
Python :: python how to run code in ssh 
Python :: python OSError: [Errno 22] Invalid argument: 
Python :: python nested object to dict 
Python :: activate virtual environment python in linux 
Python :: join tables in django orm 
Python :: add column to dataframe pandas 
Python :: python get file size 
Python :: floor python 
Python :: Interfaces 
Python :: python program to find sum of array elements 
Python :: transcript with timestamps in python 
Python :: python Entry default text 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =