在 Julia 中获取数字的阶乘 - factorial() 方法
factorial()
是 julia 中的内置函数,用于返回指定数字n的阶乘。
Syntax: factorial(n::Integer)
Parameters:
- n: Specified number
Returns: It returns the factorial of the specified number n.
示例 1:
# Julia program to illustrate
# the use of factorial() method
# Getting the factorial of
# the specified number
println(factorial(0))
println(factorial(1))
println(factorial(2))
输出:
1
1
2
示例 2:
# Julia program to illustrate
# the use of factorial() method
# Getting the factorial of
# the specified number
println(factorial(5))
println(factorial(7))
println(factorial(big(20)))
println(factorial(big(15)))
输出:
120
5040
2432902008176640000
1307674368000