An open API service indexing awesome lists of open source software.

https://github.com/letsdeepchat/the-fibonacci-sequence-using-java


https://github.com/letsdeepchat/the-fibonacci-sequence-using-java

acciojob acciojobsolution fibonacci fibonaccisequence java sequence series

Last synced: 6 months ago
JSON representation

Awesome Lists containing this project

README

          

# The-fibonacci-Sequence-using-Java

The Fibonacci Sequence
The Fibonacci sequence appears in nature all around us, in the arrangement of seeds in a sunflower and the spiral of a nautilus for example.

The Fibonacci sequence begins with fibonacci(0)=0 and fibonacci(1)=1 as its first and second terms. After these first two elements, each subsequent element is equal to the sum of the previous two elements.

Programmatically:

fibonacci(0)=0 fibonacci(1)=1 fibonacci(n)=fibonacci(n-1)+fibonacci(n-2)

Given n, return the nth number in the sequence.

n=5
The Fibonacci sequence to 6 is fs=[0,1,1,2,3,5,8].With zero-based indexing,fs[5]=5.
Problem description
Complete the code in the editor.

Input:
Contains a single integer,n.

Output:
int: the nth element in the Fibonacci sequence

Constraints
0