# Fibonacci

Not elegant, but effective:

#!/bin/bash
n1=0
n2=1
c=1
while [ 0==0 ]
do
s=`echo “\$n1+\$n2” | bc`
count=`echo “\$c+1” | bc`
echo -e “\$c\t\$s”
n1=\$n2
n2=\$s
done

Threw it together to demonstrate to Boy Wonder how to devise the sequence. Actually, this is the one I started with in pseudocode on the side of the refrigerator then it morphed into the one above to make it work in bash:
n1=0
n2=1
do
result=n1+n2
print result
n1=n2
n2=result
loop
Serves very little practical purpose other than to learn and see the relationship of numbers.

This site uses Akismet to reduce spam. Learn how your comment data is processed.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8705935,"math_prob":0.6550133,"size":531,"snap":"2021-21-2021-25","text_gpt3_token_len":178,"char_repetition_ratio":0.09677419,"word_repetition_ratio":0.0,"special_character_ratio":0.3088512,"punctuation_ratio":0.060869563,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96925694,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-05-10T02:26:32Z\",\"WARC-Record-ID\":\"<urn:uuid:ef56a31d-33fc-49fd-aaac-64e0e5bb7fdf>\",\"Content-Length\":\"88600\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ad6786bd-bd91-4289-abde-9352eacb4550>\",\"WARC-Concurrent-To\":\"<urn:uuid:a6abc764-669b-4e34-aa24-a9831d8c182a>\",\"WARC-IP-Address\":\"192.0.78.25\",\"WARC-Target-URI\":\"https://esthermofet.com/2011/01/24/fibonacci/\",\"WARC-Payload-Digest\":\"sha1:BLEBXSCKLBGTEA3NVHSXHQHFMNTGUFON\",\"WARC-Block-Digest\":\"sha1:NSVA5JOTPJWAZOUSEJ5MBCUO3Y6LWZVL\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-21/CC-MAIN-2021-21_segments_1620243989030.65_warc_CC-MAIN-20210510003422-20210510033422-00305.warc.gz\"}"}