Current Path : /compat/linux/proc/68247/root/compat/linux/proc/68247/root/compat/linux/usr/share/doc/bash-3.2/functions/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //compat/linux/proc/68247/root/compat/linux/proc/68247/root/compat/linux/usr/share/doc/bash-3.2/functions/fact |
# Who said shells can't use recursion? Here is a factorial function. # You call it with a number as an argument, and it returns the factorial # of that number. fact () { local num=$1; if [ "$num" = 1 ] ; then echo 1 return ; fi; echo $(( $num * $(fact $(( $num - 1 )) ) )) }