Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Selve programmet. Factorial betyder fakultet.
- def factorial num
- if num < 0
- return 'You can\'t take the factorial of a negative number!'
- end
- if num <= 1
- 1
- else
- num * factorial(num-1)
- end
- end
- # Et par eksempler...
- puts factorial(3)
- puts factorial(30)
Add Comment
Please, Sign In to add comment