Created
January 11, 2023 07:57
-
-
Save manojjha/4432ea2d1e217b8d02f5bdf9783d567f to your computer and use it in GitHub Desktop.
Shell script to find factorial of a number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Enter a number:" | |
read number | |
factorial=1 | |
counter=$number | |
while [ $counter -gt 0 ] | |
do | |
factorial=$((factorial * counter)) | |
counter=$((counter - 1)) | |
done | |
echo "The factorial of $number is $factorial" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment