Download benchmarks/Algorithms/integer_divide/lean/solution_spec.c from PV-SJTU/PV-Bench: direct link, hf CLI and curl.
- Browser
- Download file 755 Bytes
-
https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/integer_divide/lean/solution_spec.c
- Command line
-
hf download hf://datasets/PV-SJTU/PV-Bench/benchmarks/Algorithms/integer_divide/lean/solution_spec.c
-
curl -L -o solution_spec.c https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/integer_divide/lean/solution_spec.c
755 Bytes
| /*@ Import Lean | |
| import Algorithms.integer_divide.lean.spec_lib | |
| open scoped SimpleC | |
| */ | |
| /*@ Extern Coq | |
| (PrimeFactorization : Z -> list Z -> Prop) | |
| */ | |
| void divide(int n, int *p) | |
| /*@ With (original : Z) | |
| Require | |
| n == original && | |
| 1 <= original && original <= INT_MAX && | |
| IntArray::undef_full(p, original) | |
| Ensure | |
| exists factors, | |
| PrimeFactorization(original, factors) && | |
| Zlength(factors) < original && | |
| IntArray::undef_seg(p, 0, 1) * | |
| IntArray::seg(p, 1, 1 + Zlength(factors), factors) * | |
| IntArray::undef_seg(p, 1 + Zlength(factors), original) | |
| */ | |
| { | |
| int cnt = 0; | |
| for (int i = 2; i <= n; i++) { | |
| while (n % i == 0) { | |
| cnt++; | |
| p[cnt] = i; | |
| n /= i; | |
| } | |
| if (n == 1) { | |
| break; | |
| } | |
| } | |
| } | |