factorial_mod
std.elementwise.factorial_mod · Level L4n! mod m, elementwise, multiplying 1 … n and reducing modulo m at every step, so nothing grows past m·n. Wilson's theorem says (p − 1)! ≡ −1 (mod p) exactly when p is prime.
n! mod m
Signature
factorial_mod(n: i64[s], m: i64[s]) → i64[s]
Structure
The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.
- input
- operation
- constant
- call
- output
Verification
- Signature proven by NOVA’s shape solver, for every size.
- Equal to the reference
math.factorial(n) % min exact rational arithmetic, on all 40 test cases. - All 160 int64 results are exact: the error is zero.
- Interpreter and NumPy backend return bit-identical results.
- At float32 too: the 40 test cases rounded to float32, and 40 of them exact, with zero error.
Accuracy in detail
- correctly rounded (the int64 nearest the exact value)
- 100%
- bit-equal to the NumPy formula in int64
- 100%
- largest error, in units in the last place
- 0
Identity
sha256:27b2ccfaeee314a8f82eea19a0b53b12c66ab8be5f17a5f729475f6cdca93ad1The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.
Control handle
- Symbol
- Ω:std.elementwise.factorial_mod · Ω:factorial_mod
- Pins
sha256:e9aa5a5a5ab98f6881c0e5fc60b3aeb0e4ded61fdc7a7d45d004a901f2012db5this graph and the 2 it reaches through calls- Evidence
sha256:48cc2a9b134da6fd1b4d93539c6b5d6ab29fd2cf64251b9f0659bc5b1a4a07dathe hash of its verification record- Needs
- no capability: a pure function
Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.