51 lines
1.6 KiB
Markdown
51 lines
1.6 KiB
Markdown
---
|
|
epic: 6
|
|
story: 6.3
|
|
title: "Factorial & Combinatorics"
|
|
status: draft
|
|
---
|
|
|
|
## Epic 6 — Advanced Math & Functions
|
|
**Goal:** Scientific, financial, and power-user math.
|
|
|
|
### Story 6.3: Factorial & Combinatorics
|
|
|
|
As a **CalcPad user**,
|
|
I want to compute factorials, permutations, and combinations,
|
|
So that I can solve probability, statistics, and combinatorics problems.
|
|
|
|
**Acceptance Criteria:**
|
|
|
|
**Given** the user writes `10!`
|
|
**When** the engine evaluates
|
|
**Then** the result is `3628800`
|
|
|
|
**Given** the user writes `0!`
|
|
**When** the engine evaluates
|
|
**Then** the result is `1` (by mathematical convention)
|
|
|
|
**Given** the user writes `nPr(10, 3)`
|
|
**When** the engine evaluates
|
|
**Then** the result is `720` (10! / 7!)
|
|
|
|
**Given** the user writes `nCr(10, 3)`
|
|
**When** the engine evaluates
|
|
**Then** the result is `120` (10! / (3! * 7!))
|
|
|
|
**Given** the user writes `100!`
|
|
**When** the engine evaluates
|
|
**Then** the result is computed using arbitrary precision arithmetic and is exact (not a floating-point approximation)
|
|
**And** the full integer result is displayed (or a scrollable/expandable representation for very large numbers)
|
|
|
|
**Given** the user writes `(-3)!`
|
|
**When** the engine evaluates
|
|
**Then** an error is displayed (factorial of negative integers is undefined)
|
|
|
|
**Given** the user writes `3.5!`
|
|
**When** the engine evaluates
|
|
**Then** either the gamma function is used to compute `Gamma(4.5)` approximately `11.6317`, or an error indicates that only non-negative integer factorials are supported
|
|
|
|
**Given** the user writes `nCr(5, 7)` where k > n
|
|
**When** the engine evaluates
|
|
**Then** the result is `0` (by combinatorial convention)
|