我尝试了bc但是如果我试图找到数字50的阶乘,它显示我1而不是30414093201713378043612608166064768844377641568960512000000000000
read T
while ((T--)); do
read n
factorial=1
for ((i = 1; i <= $n; i++)); do
factorial=$(( i * factorial ))
done
echo $factorial
done
答案 0 :(得分:3)
使用 bc 可以正常工作:
echo "define f (x) {
if (x <= 1) return (1);
return (f(x-1) * x);
}
f(50) " | bc