cielseven's picture
add benchmark corpora, groundtruth, symexec scripts and coverage docs
bff4ec7
Raw History Blame Contribute Delete
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;
}
}
}