Mode:
Duration:
1
2
3
4
5
6
7
8
9
factorial() {
if [ $1 -le 1 ]; then
echo 1
else
echo $(( $1 * $(factorial $(( $1 - 1 ))) ))
fi
}
echo "Factorial of 5: $(factorial 5)"Coding works best on desktop or with an external keyboard.
factorial() {
if [ $1 -le 1 ]; then
echo 1
else
echo $(( $1 * $(factorial $(( $1 - 1 ))) ))
fi
}
echo "Factorial of 5: $(factorial 5)"Coding works best on desktop or with an external keyboard.
Recursive factorial calculation.
factorial() {
if [ $1 -le 1 ]; then
echo 1
else
echo $(( $1 * $(factorial $(( $1 - 1 ))) ))
fi
}
echo "Factorial of 5: $(factorial 5)"Bash (Bourne Again SHell) is a Unix shell and command language widely used for automation, scripting, DevOps, system administration, and shell-based application workflows. It is the default shell on most Linux systems and offers powerful command-line capabilities.
Origin & Creator
Created by Brian Fox at the Free Software Foundation in 1989 as a free replacement for the Bourne Shell (sh).
Industrial Note
Bash excels in environments requiring quick system automation, CI/CD pipelines, container orchestration scripts, server automation, cloud provisioning scripts, and Unix-level glue code that ties together native tools.