11 #ifndef PROGS_SRC_COMMON_SIGMAODD_DIVISORS_HPP_ 12 #define PROGS_SRC_COMMON_SIGMAODD_DIVISORS_HPP_ 66 std::vector<FactorExp>
79 std::pair<nat_type, unsigned int>
102 std::pair<nat_type, unsigned int>
354 #endif // PROGS_SRC_COMMON_SIGMAODD_DIVISORS_HPP_ Define type and some generic functions.
nat_type sum_odd_divisors__naive(nat_type n)
Calculates the sum of odd divisors of n by the naive method and returns it.
uint64_t nat_type
Type for natural number used in all code, on 64 bits.
Structure to represent a factor with its exponent.
constexpr bool is_unitary_divide(nat_type d, nat_type n)
Return true iff (d divide n) and (d NOT divide n/d).
nat_type sum_odd_divisors_upper_bound__DeTemple_ceil(nat_type n)
Return an upper bound of sum odd divisors of n using the DeTemple inequalities. ???
nat_type pollard_rho_repeat(nat_type n, nat_type nb_tries)
Try pollard_rho(n) a maximum of nb_tries times and return 0 or the first divisor find.
nat_type sum_divisors__naive(nat_type n)
Calculates the sum of all divisors of n by the naive method and returns it.
std::pair< nat_type, unsigned int > divide_until_odd_nb(nat_type n)
Divide n by 2 until the result is odd, and return (result, number of divisions).
nat_type divide_until_odd(nat_type n)
Return n divided by 2 until the result is odd.
nat_type first_divisor(nat_type n)
Return the first divisor of n > 1 (or 1 if n <= 1)
bool is_square(nat_type n)
Return true iff n is a perfect square.
A lot of functions and stuffs to deal the sigma_odd problem and related stuffs.
std::ostream & operator<<(std::ostream &out, const FactorExp &factor_exp)
Return "factor^exponent" representation of factor_exp.
constexpr bool is_mersenne_prime_unitary_divide(nat_type n)
Return true iff at least one of 3, 7, 31, 127, 8191, 131071, 524287, 2147483647 or 230584300921369395...
constexpr bool is_divide(nat_type d, nat_type n)
Return true iff d divide n, i.e. if n is divisible by d.
constexpr bool operator==(const FactorExp &other) const
nat_type sum_odd_divisors__factorize(nat_type n)
Calculates the sum of odd divisors of n by the factorization method and returns it.
nat_type sum_odd_divisors_upper_bound(nat_type n)
Return an upper bound of sum odd divisors.
constexpr nat_type gcd(nat_type a, nat_type b)
Return the Greatest Common Divisor of a and b.
nat_type sum_divisors__factorize(nat_type n)
Calculates the sum of all divisors of n by the factorization method and returns it.
constexpr bool is_first_mersenne_prime_unitary_divide_or_square(nat_type n)
Return true iff is_first_mersenne_prime_unitary_divide(n) or is_square(n).
std::vector< FactorExp > coprime_factor_exps(nat_type a, nat_type b)
Heuristic to return a list of factors with their exponents such that all factors are coprimes and the...
constexpr bool is_little_mersenne_prime_unitary_divide(nat_type n)
Return true iff at least one of 3, 7, 31, 127, 8191, 131071 or 524287 is an unitary divisor of n...
constexpr bool is_first_mersenne_prime_unitary_divide(nat_type n)
Return true iff at least one of 3, 7, 31 or 127 is an unitary divisor of n.
constexpr nat_type value() const
std::pair< nat_type, unsigned int > divide_until_nb(nat_type n, nat_type d)
Divide n by d until the result is not divisible by d, and return (result, number of divisions)...
constexpr nat_type is_coprime(nat_type a, nat_type b)
Return true iff a and b are coprime (relatively prime).
nat_type sum_odd_divisors_upper_bound__DeTemple(nat_type n)
Return an upper bound of sum odd divisors of n using the DeTemple inequalities.
nat_type pollard_rho(nat_type n)
Return pollard_rho(n, rand() % n, floor square root of n).