RosettaCodeData/Task/Factorial/Crystal/factorial-2.cr

7 lines
98 B
Crystal
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
def factorial(x : Int)
if x <= 1
return 1
end
return x * factorial(x - 1)
end