brewersfan1976

least_factorial.rb

Aug 25th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.25 KB | None | 0 0
  1. def leastFactorial(n)
  2.     def factorial(n = 0)
  3.         (1..n).inject(:*)
  4.     end
  5.    
  6.     x = 1
  7.    
  8.     while(true)
  9.         if factorial(x) >= n then
  10.             return factorial(x)
  11.         else
  12.             x = x + 1
  13.         end
  14.     end
  15. end
Advertisement
Add Comment
Please, Sign In to add comment