Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo "<<--------MENU----------->>"
  4. echo "We will do a factorial"
  5. echo "Enter the number"
  6. read num
  7. echo "You entred " $num
  8. fact() #Function to calculate factorial of the given number
  9. {
  10. if (num -eq 0)
  11. then
  12. echo "1"
  13. elif (num -lt 0)
  14. then
  15. echo "Negative number can not be factorialed"
  16. else
  17. return fact*fact (n-1)
  18. fi
  19. }
  20.  
  21. fact $num
  22.  
  23. echo "The result is :" $fact(num)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement