Nandakumar
Content Network

You are not logged in.
Click here to login.

Some part of this library is not public. You must register to get exclusive access. If you are already registered, click here to login.


Shell Programming >> 2017

Shell Script to Find Fibonacci Numbers Using Recursion

By | | License: proprietary


Code

Updated on Apr 8, 2017, 5:47 PM IST: Minor edit that fixed the bug which had prevented the last number in the series from being printed.

#!/bin/bash

function fibo {
	echo $1 # No 1

	if [ $2 -gt $3 ] ;then # $3 = Max
		return
	fi

	fibo $2 $(expr $1 + $2) $3
}

echo -n "Enter the upperlimit: "
read limit

fibo 0 1 $limit

Keywords (click to browse): fibonacci recursion function shell sh bash linux gnu unix script programming command-line

Shell Script to Find Fibonacci Numbers Using Recursion | Nandakumar Content Network
Copyright © 2015, 2016, 2017 Nandakumar Edamana.