code for chapter 3 in ruby
This commit is contained in:
9
03_recursion/ruby/03_factorial.rb
Normal file
9
03_recursion/ruby/03_factorial.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
def fact(x)
|
||||
if x == 1
|
||||
1
|
||||
else
|
||||
x * fact(x - 1)
|
||||
end
|
||||
end
|
||||
|
||||
puts fact(5)
|
||||
Reference in New Issue
Block a user