Fibonacci Sequence

Generate the first N numbers of the Fibonacci sequence where each number is the sum of the two preceding ones.

Code

Algorithms
a=0; b=1; for ((i=0; i<n; i++)); do echo -n "$a "; c=$((a+b)); a=$b; b=$c; done | sed 's/ $//'

Parameters

Number of Fibonacci numbers to generate

Server

More Bash Snippets