The Fibonacci Sequence

In different languages

Bash #!/bin/bash function fibonacci { local n=$1 [[ $n == 0 ]] && echo $n && return [[ $n == 1 ]] && echo $n && return local x=$(fibonacci $((n - 1))) local y=$(fibonacci $((n - 2))) echo $((x + y)) } echo -e sh\\t$(fibonacci 14) C #include <stdio.h> unsigned int fibonacci(const unsigned int); int main() { printf("c\t%d\n", fibonacci(14)); return 0l; } unsigned int fibonacci(const unsigned int n) { return ( n < 2 ? [Read More]