Understand the concept of functions in Julia by defining one that calculates factorials.
function factorial(n)
if n == 0
return 1
else
return n * factorial(n - 1)
end
end
result = factorial(5)
println("Factorial of 5 is $result")