MCPcopy Create free account
hub / github.com/cp-algorithms/cp-algorithms / main

Function main

test/test_factorization.cpp:33–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31#include "../test/pollard_rho_brent.h"
32
33int main() {
34 map<long long, vector<long long>> test_data = {
35 {132, {2, 2, 3, 11}},
36 {123456789, {3, 3, 3607, 3803}},
37 {4817191, {1303, 3697}}
38 };
39 primes = {2, 3, 5, 7, 1303, 3607};
40
41 for (auto n_expected : test_data) {
42 auto n = n_expected.first;
43 auto expected = n_expected.second;
44
45 assert(trial_division1(n) == expected);
46 assert(trial_division2(n) == expected);
47 assert(trial_division3(n) == expected);
48 assert(trial_division4(n) == expected);
49
50 long long g = pollards_p_minus_1(n);
51 assert(g > 1 && g < n && n % g == 0);
52
53 g = rho(n);
54 assert(g > 1 && g < n && n % g == 0);
55 g = brent(n);
56 assert(g > 1 && g < n && n % g == 0);
57 }
58}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected