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! עולה על שני מיליארדים טריליונים — ולכן השיטה מחזירה long ולא int, אחרת התשובה תגרום לעריכת יתר (overflow). כפל מ-2 ועד ל-n.

Log in or create account · ⁨היכנס או צור חשבון⁩

IGCSE, A-Level & AP