#!/bin/bash input=$1 fact_op=1 while[$input-gt0] do echo"$fact_op$input" fact_op=$(($fact_op*$input)) input=$(($input - 1)) done echo"factorial of value $1 is $fact_op"
OUTPUT: sujin@sujin:~/work/shell$ ./factorial.sh 5 1 5 5 4 20 3 60 2 120 1 factorial of value 5 is 120
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.