answersLogoWhite

0

fibo()

{

num=${1:-100}

n2=1

n1=0

while n=$(( $n1 + $n2 )); [ $n -le $num ]

do

printf "%d " "$n"

n1=$n2

n2=$n

done

echo

}

## The loop continues until the user enters a valid number

while :

do

printf "Enter a number: "

read number

case $number in

*[!0-9]* | "") printf "\a*** Invalid number ***\n" >&2 ;;

*) break ;;

esac

done

fibo "$number"

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Write a c program Fibonacci series using for loop in java?

Exactly what do you mean by 'C program in Java'


Write a unix program to print print a pattern?

echo 'print a pattern'


Is the kernel in a unix os a program?

The kernel is the central control program of Unix and the majority of other operating systems.


Unix script to calculate average of n numbers given by user?

You really don't want to do this in a shell script - scripting languages in Unix typically do not handle or work with floating values, only integers. A better way would be to write a program to do this that works under Unix, such as a 'C" program. See the related link for an example


Is Unix is a type of utility program?

No, Unix is an operating system program. A utility program cannot run by itself; it runs under an operating system.


How do you write a c program for diff command that we use in unix?

Too difficult to answer here. I would find the source code and use that (if you really had to). Might require a 'port' to another operating system if it wasn't Unix based.


How can you debug a C program in Unix?

You can debug C programs using gdb on Unix.


What is portablity in terms of unix?

Unix is inherently portable; this means that a program, script, or process may be moved from Unix system to Unix system with little effort or change (hence - portable).


How do you write a c program to calculate the Fibonacci series of a given number?

To write a C program that calculates the Fibonacci series up to a given number, you can use a loop to generate the series. Start by initializing the first two Fibonacci numbers (0 and 1) and then repeatedly compute the next number by adding the two preceding numbers until you reach or exceed the specified limit. Here’s a simple example: #include <stdio.h> int main() { int n, t1 = 0, t2 = 1, nextTerm; printf("Enter a positive integer: "); scanf("%d", &n); printf("Fibonacci Series: %d, %d", t1, t2); for (int i = 3; i <= n; ++i) { nextTerm = t1 + t2; printf(", %d", nextTerm); t1 = t2; t2 = nextTerm; } return 0; } This program prompts the user for a number and prints the Fibonacci series up to that number.


How do you run a Unix program?

By typing its name into the shell


Definition of a program in UNIX?

Something what the computer executes.


What is a mini shell program used for in Unix?

The mini shell program is used in Unix as a programming software. It is a redirected and streamlined approach at creating variables, commands, and tokens.