Rumel

Factorial

Mar 25th, 2011
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.12 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. x=$1
  4. y=$x-1
  5. z=0
  6. while [ $x -gt 1 ]
  7. do
  8.     z=$x*$y+$z
  9.     x--
  10.     y--
  11. done
  12. echo "The factorial of $1 is $z!"
Advertisement
Add Comment
Please, Sign In to add comment