PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Bash Fibonacci Sequence Generator

Go down

Bash Fibonacci Sequence Generator Empty Bash Fibonacci Sequence Generator

Post by jamied_uk 6th March 2016, 18:43

Bash Fibonacci Sequence Generator





https://app.box.com/s/cx77cvrdk90ae5nzk8meq8yf9bkj9lku

Example 1

Code:
#!/bin/bash
# (c) J~Net 2021
# jnet.sytes.net
#
# ./fib.sh 999999999999999999999999999999999999999999999999"
#
#
longnumber="999999999999999999999999999999999999999999999999"
#
echo "Max Lengh "
echo -n "$longnumber" | wc -c
#
echo "Welcome To Fibinatchi By (c) J~Net 2021"
 if [ "$#" -eq  "0" ]
   then
     echo "Enter Max Number For Example"
     echo "$longnumber"
     echo ""
     read term
 else
     term=$1
 fi
#
i=0
j=1
for ((i=1; i<term/2+1; i++)) ; do
    (( n=i+j ))
    (( i=j ))
    (( j=n ))
    echo $i
done


Last edited by jamied_uk on 4th March 2022, 12:30; edited 1 time in total
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Bash Fibonacci Sequence Generator Empty Re: Bash Fibonacci Sequence Generator

Post by jamied_uk 4th March 2022, 12:27

Example 2


Code:
#!/bin/bash
# (c) J~Net 2022
# jnet.sytes.net
#
# https://jnet.forumotion.com/t1070-bash-fibonacci-sequence-generator#1429
#
#
# ./fib2.sh 999999999999999999999999999999999999999999999999"
#
set -e
#clear
f1=0;f2=1 # 0 1
f3=`expr $f1 + $f2`
 if [ "$#" -eq  "0" ]
   then
echo "Max Lengh "
read n

else
    n=$1
fi

i=3
while [ $i -le $n ]
do
    echo $f3
    f1=$f2
    f2=$f3
    f3=`expr $f1 + $f2`
    i=`expr $i + 1`
done
set +e
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Bash Fibonacci Sequence Generator Empty Re: Bash Fibonacci Sequence Generator

Post by jamied_uk 4th March 2022, 19:45

your job is to find out how accurate it is and make it more accuate

then make it it go indefenatly forever finding new long numbers without getting errors while keeping it accurate!


Post your code below!
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Bash Fibonacci Sequence Generator Empty Re: Bash Fibonacci Sequence Generator

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum