Factorial · 階乗
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
The factorial n! is the product 1 * 2 * 3 * ... * n. By definition 0! is 1.
Start a result at 1, then multiply it by every integer from 2 up to n in a loop. (The tests keep n at most 10, so the answer fits in an int.)
日本語
階乗
阶乗 n! は积 1 * 2 * 3 * ... * n です。定義により 0! は 1 です。
結果を 1 で始め、2 から n までのすべての整数をループで掛け合わせます。(テストは n を最大 10 に保ちますので、答えは int に収まります。)
Complete int factorial(int n) to return n! = 1 * 2 * ... * n. Assume 0 <= n <= 10, and factorial(0) is 1. · int factorial(int n) を完成させて n! = 1 * 2 * ... * n を返します。0 <= n <= 10 と仮定し、factorial(0) は 1 です。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。