Monday, 2 April 2018

Shell script to find m to the power n



echo "Enter the m And n"
read m n
 
#Script to find m power n                                                                                        power=1                                                                                                                                      
for((i=1; i <= n; i++))
do                                                                                                                                                                                                                                                     
          power=`expr $power \* $m`
                                                                                                                       
done                                                                                                                                            
echo "$m power $n = $power"




OUTPUT

csc@csc-SVE1513CYNB ~ $ bash power.sh
Enter the m And n
4 3
4 power 3 = 64

No comments:

Post a Comment