WA Shell script part 2

1. WA Shell script to find Fibonacci series of a given number.

echo "enter number"
read n
k=1
i=0
j=1
echo $i
while [ $k -le $n  ]
do
      echo $k
      k=`expr $i + $j`
      i=$j
      j=$k
done

2. WA Shell script to find Fibonacci series of a given number.

echo "Enter Number"
read n
sd=0
no=$n

while [ $n -gt 0  ]
do
      sd=`expr $n % 10`
      n=`expr $n / 10`
      s=$s$sd
done

if [ $no -eq $s ]
then
      echo "pelidrom"
else
      echo "not pelindrom"
fi

2. WA Shell script to find palindrome of a given number.

echo "Enter Number"
read n
sd=0
no=$n

while [ $n -gt 0  ]
do
      sd=`expr $n % 10`
      n=`expr $n / 10`
      s=$s$sd
done

if [ $no -eq $s ]
then
      echo "pelidrom"
else
      echo "not pelindrom"
fi


3. WA Shell script to find Amstrong number or not.

echo "Enter No"
read n
l=`expr length $n`
i=1
while [ $i -le $l ]
do
      r=`expr $n | cut -c $i`
      let i++
      m=`expr $r \* $r \* $r`
      s=`expr $s + $m`
     
done

if [ $s -eq $n  ]
then
echo "No. is Amstrong"
else
echo "No. is not Amstrong"

fi