Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo "<<--------MENU----------->>"
- echo "We will do a factorial"
- echo "Enter the number"
- read num
- echo "You entred " $num
- fact() #Function to calculate factorial of the given number
- {
- if (num -eq 0)
- then
- echo "1"
- elif (num -lt 0)
- then
- echo "Negative number can not be factorialed"
- else
- return fact*fact (n-1)
- fi
- }
- fact $num
- echo "The result is :" $fact(num)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement