Factorial (mind the size) · 階乗(サイズに注意)
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
English
Factorial (mind the size)
n! is 1 × 2 × … × n, and 0! is 1. It grows fast — 20! is over two billion billion — so the method returns a long, not an int, or the answer would overflow. Multiply from 2 up to n.
日本語
階乗(サイズに注意)
n!は1 × 2 × … × n、0!は1です。値は急激に増加します——20!は2兆以上——因此、この方法がlongを返さずintを返すと、答えはオーバーフローしてしまいます。2からnまで掛け算を行います。
Complete factorial(int n) returning n! as a long (so large values fit). factorial(0) is 1. Assume 0 <= n <= 20. · factorial(int n) を完成させて n! を long として返してください(大きな値も収まるように)。factorial(0) は 1 です。0 <= n <= 20 と仮定します。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。