Guest User

Untitled

a guest
May 21st, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.20 KB | None | 0 0
  1. module MathFunctions
  2. def self.factorial(n)
  3. (1..n).inject(1) { |acc, x| acc * x}
  4. end
  5. end
  6.  
  7. =begin :unittest
  8.  
  9. assert MathFunctions.factorial(6) == 720
  10. assert MathFunctions.factorial(5) == 120
  11.  
  12. =end
Add Comment
Please, Sign In to add comment