Skip to content

Instantly share code, notes, and snippets.

@manojjha
Created January 11, 2023 07:57
Show Gist options
  • Save manojjha/4432ea2d1e217b8d02f5bdf9783d567f to your computer and use it in GitHub Desktop.
Save manojjha/4432ea2d1e217b8d02f5bdf9783d567f to your computer and use it in GitHub Desktop.
Shell script to find factorial of a number
#!/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