[LINUX] A shell program that displays the Fibonacci sequence


I created it as a small story of Bash programming. This is the 5th bullet.

Show Fibonacci sequence

For more information on what the Fibonacci sequence is, click here [https://en.wikipedia.org/wiki/%E3%83%95%E3%82%A3%E3%83%9C%E3%83%8A% Please check E3% 83% 83% E3% 83% 81% E6% 95% B0).

Simply put, it is a sequence that can be created by adding the previous term and the previous term.




echo -n "please input number => "
read num

if (( $num <= 1 || $num >= 2))
  echo $m
  echo $n
(( num +=2 ))

for i in $(seq 1 $num)
  (( o = $m + $n ))
  echo $o

I think I can write more beautifully ...

Execution result

$ ./fibonacci.sh
please input number => 8

in conclusion

By creating this program

--read command --Conditional expression --Conditional operator --Variables --Bash's manners

I understand.

Recommended Posts

A shell program that displays the Fibonacci sequence
[Python] A program that rounds the score
A program that searches for the same image
[Python] A program that counts the number of valleys
A shell program that becomes aho in multiples of 3
[Python] A program that compares the positions of kangaroos.
[Python] A program for finding the Fibonacci sequence (recursive function, divide-and-conquer method, dynamic programming method)
A program that removes specific characters from the entered text
A shell script that just emails the SQL execution result
A program that just presses and releases the Esc key
Is there a bias in the numbers that appear in the Fibonacci numbers?
[Python] A program that finds the most common bird types
A script that displays the running CloudFormation stack like a mannequin
[Golang] A program that determines the turn with random numbers
Thank you for the Fibonacci sequence.
Sample program for finding Fibonacci sequence
The story of writing a program
I made a program that solves the spot the difference in seconds
[Ev3dev] Create a program that captures the LCD (screen) using python
Try to write a program that abuses the program and sends 100 emails
I made a program that automatically calculates the zodiac with tkinter
[Python] A program that rotates the contents of the list to the left
[Python] A program that creates stairs with #
[Python] A program that calculates the number of chocolate segments that meet the conditions
A class that hits the DMM API
A program that will slowly recover the economy from any news headline
A code that corrects the yoon / sokuon (sokuon)
A program that plays rock-paper-scissors using Python
Create a BOT that displays the number of infected people in the new corona
[Python] A program that calculates the difference between the total numbers on the diagonal line.
[Python] A program that calculates the number of updates of the highest and lowest records
A model that identifies the guitar with fast.ai
Nogizaka46 A program that automatically saves blog images
The one that displays the progress bar in Python
Try creating a FizzBuzz problem with a shell program
A program that notifies slack of the operating status of fully automatic botanical photography equipment
A program that summarizes the transaction history csv data of SBI SECURITIES stocks [Python3]
There is a pattern that the program did not stop when using Python threading
A note that runs an external program in Python and parses the resulting line
Recursive function that displays the XML tree structure [Note]
Make a BOT that shortens the URL of Discord
A programming language that protects the people from NHK
# Function that returns the character code of a string
A story that struggled with the common set HTTP_PROXY = ~
A shell script that puts Webmin into Alpine Linux
Python program that looks for the same file name
Generate that shape of the bottom of a PET bottle
A memo that I touched the Datastore with python
Modules that may go through the shell in Python
A story that analyzed the delivery of Nico Nama.
A Python program that converts ical data into text
A program that automatically resizes the iOS app icon to the required image size in Python
[Note] A shell script that checks the CPU usage of a specific process in a while loop.