17 #include "../helper/helper.hpp" 79 const auto it = sum_divisors__euler__cache_.find(n);
81 if (it != sum_divisors__euler__cache_.cend()) {
87 unsigned int alpha = 0;
97 for (
unsigned int i = 0; i < 10; ++i) {
101 unsigned int alpha = 0;
118 if ((n < pi) && (n < pi_neg)) {
137 auto it = sum_divisors__euler__cache_.begin();
140 static_cast<unsigned int>(std::rand())
141 % (sum_divisors__euler__cache_max_nb_ - 10));
142 sum_divisors__euler__cache_.erase(it);
144 sum_divisors__euler__cache_[n] = sum;
159 return sum_divisors__euler__cache_.size();
constexpr nat_type sum_geometric_progression_strict(nat_type r, unsigned int k)
Return sum_geometric_progression(r, k) but only for r > 1.
uint64_t nat_type
Type for natural number used in all code, on 64 bits.
constexpr bool is_odd(nat_type n)
Return true iff n is odd.
Functions to calculate pentagonal numbers and one useless algorithm that used the Euler formula to ca...
constexpr bool is_even(nat_type n)
Return true iff n is even.
size_t sum_divisors__euler__table_nb_
std::size_t sum_divisors__euler_cache_nb()
Return the current number of items in the cache used by sum_divisors__euler()
constexpr nat_type pentagonal_neg(nat_type n)
Return the generalized pentagonal number of -n.
A lot of functions and stuffs to deal the sigma_odd problem and related stuffs.
bool sum_divisors__euler_cache_is_full()
Return true iff the cache used by sum_divisors__euler() is full. The function can clean space...
constexpr nat_type pentagonal(nat_type n)
Return the pentagonal number of n.
std::vector< nat_type > sum_divisors__euler__table_(sum_divisors__euler__table_nb_)
constexpr bool is_divide(nat_type d, nat_type n)
Return true iff d divide n, i.e. if n is divisible by d.
std::map< nat_type, nat_type > sum_divisors__euler__cache_
Functions to access to tables of precaculated prime numbers and offsets to iterate on possible prime ...
std::size_t sum_divisors__euler_table_nb()
Return the (constant) number of items in the table used by sum_divisors__euler()
prime_type odd_primes_table_by_index(unsigned int i)
Return the (i + 1)th odd prime number from the precalculated table.
size_t sum_divisors__euler__cache_max_nb_
nat_type sum_divisors__euler(nat_type n)
Calculates the sum of all divisors of n with the Euler formula about pentagonal numbers and returns i...
Functions in link with divisor notion: sum of divisors, factorization, GCD, coprime, ...
nat_type sum_divisors_diff_(nat_type n, nat_type pi)