Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module MathFunctions
- def self.factorial(n)
- (1..n).inject(1) { |acc, x| acc * x}
- end
- end
- =begin :unittest
- assert MathFunctions.factorial(6) == 720
- assert MathFunctions.factorial(5) == 120
- =end
Add Comment
Please, Sign In to add comment