Monday, December 12, 2022

finding factorial of a number using bash one liner

 read -rep $'enter the number whose factorial you want\n' fact && result=1 && for i in $(seq 1 $fact) ;do result=$((result*i));don
e && echo $result

 

 

read -rep $'enter number\n' num && (echo 1; seq $num) | paste -s -d "\*" | bc

No comments:

Post a Comment