Advertisement
Shailrshah

Factorial

Nov 2nd, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.18 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. echo -n "Enter the limit: "
  4. read n
  5.  
  6. if [ $n -lt 0 ]; then
  7.     echo "Not allowed"
  8.     else   
  9.         ans=1
  10.         for(( i=2; i<=$n; i++ )){
  11.             let ans*=$i
  12.         }
  13.         echo $ans
  14. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement