Skip to content

Instantly share code, notes, and snippets.

@technoburst
Created April 3, 2013 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technoburst/5298493 to your computer and use it in GitHub Desktop.
Save technoburst/5298493 to your computer and use it in GitHub Desktop.
Shell script to find the factorial of a number.
#!/bin/bash
#Script to print the factorial of a number
echo "\nThis is a script to find the factorial of a number"
declare -i count result
echo "Enter a number : "
read num
count=$num
result=1
while [ "$count" != "0" ]; do
result=result*count
count=count-1
done
echo "factirial is $result"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment