Skip to content · ⁨コンテンツへスキップ⁩

Factorial (mind the size) · ⁨階乗(サイズに注意)⁩

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まで掛け算を行います。

Log in or create account · ⁨ログインまたはアカウント作成⁩

IGCSE, A-Level & AP