Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Bash is not a good tool for large number calculation.
- # Consider Python or Ruby
- function fac {
- if [ $1 -le 1 ]; then
- echo 1
- return
- else
- echo $(( $( fac $(( $1 - 1 )) ) * $1 ))
- fi
- }
- fac 1
- fac 10
- fac 20
- fac 50 # error
- fac 100 # error
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement