Download benchmarks/Algorithms/linear_modular_inverse/solution.c from PV-SJTU/PV-Bench: direct link, hf CLI and curl.
- Browser
- Download file 249 Bytes
-
https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/linear_modular_inverse/solution.c
- Command line
-
hf download hf://datasets/PV-SJTU/PV-Bench/benchmarks/Algorithms/linear_modular_inverse/solution.c
-
curl -L -o solution.c https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/linear_modular_inverse/solution.c
249 Bytes
| void linear_modular_inverse(int p, int *inverse) | |
| { | |
| inverse[1] = 1; | |
| for (int i = 2; i < p; ++i) { | |
| int quotient = p / i; | |
| int remainder = p % i; | |
| inverse[i] = ((p - quotient) * inverse[remainder]) % p; | |
| } | |
| } | |