Skip to content

Commit

Permalink
Create factorial-functional.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
VladYermakov authored Oct 9, 2017
1 parent b672bcc commit 9dbeb7c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions math/factorial/ruby/factorial-functional.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def fact(n)
(1..n).inject :*
end

puts "Enter number: "
n = gets.to_i
puts "#{n}! = #{fact(n)}"

0 comments on commit 9dbeb7c

Please sign in to comment.