// Remove (and return) any small (< 2^16) factors std::vector<Botan::BigInt> remove_small_factors(Botan::BigInt& n) { std::vector<Botan::BigInt> factors; while(n.is_even()) { factors.push_back(2); n /= 2; } for(size_t j = 0; j != Botan::PRIME_TABLE_SIZE; j++) { uint16_t prime = Botan::PRIMES[j]; if(n < prime) { break; } Botan::BigInt x = Botan::gcd(n, prime); if(x != 1) { n /= x; while(x != 1) { x /= prime; factors.push_back(prime); } } } return factors; }