i'm trying to calculate nCr mod prime power , i found this comment which is really helpful but the formula as i understand doesn't apply to some numbers and i don't know how it works , could anyone explain it in more details ?
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | maomao90 | 163 |
2 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
i'm trying to calculate nCr mod prime power , i found this comment which is really helpful but the formula as i understand doesn't apply to some numbers and i don't know how it works , could anyone explain it in more details ?
Name |
---|
Lucas's theorem. WIKI
this works well for primes , but it doesn't work for prime power . for example try 28 choose 3 mod 27 it gives zero while the correct answer is nine .
Lucas' theorem stated that p must be a prime.
The OP said he needed nCr modulo a prime power (pSomeNumber).
I'm not sure whether Lucas' theorem still holds.
Once I've coded it in Python, maybe it'll help. (See nCk_mod_prime_power function)
Based on this paper by Andrew Granville.